getwarp/value-object

Value Object library for PHP

3.1.0 2022-08-22 13:41 UTC

This package is auto-updated.

Last update: 2024-04-22 17:32:04 UTC


README

Value Object library for PHP

GitHubPackagistInstallationUsage

Installation

Via Composer

$ composer require getwarp/value-object

Usage

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);

Change log

Please see CHANGELOG for more information on what has changed recently.

Contributing

Report issues and send pull requests in the main Warp repository. Please see contributing guide and code of conduct for details.

Credits

License

The MIT License (MIT). Please see license file for more information.