PHP code example of getwarp / value-object

1. Go to this page and download the library: Download getwarp/value-object library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

getwarp / value-object example snippets


use Warp\ValueObject\AbstractIntValue;
use Warp\ValueObject\AbstractEnumValue;

class PostId extends AbstractIntValue {
}

$postId = PostId::new(10);
\assert($int->value() === 10);
\assert(PostId::new(10) === $postId);

/**
 * @method static self public()
 * @method static self draft()
 */
class PostStatus extends AbstractEnumValue {
    public const PUBLIC = 'public';

    public const DRAFT = 'draft';
}

$draftStatus = PostStatus::draft();
$publicStatus = PostStatus::public();

\assert($draftStatus !== $publicStatus);