hyperized/value-objects
最新稳定版本:v0.5.0
Composer 安装命令:
composer require hyperized/value-objects
包简介
A basic value objects collection
README 文档
README
A basic PHP value objects collection.
Install
composer require hyperized/value-objects
Examples
Integer type
<?php declare(strict_types=1); use Hyperized\ValueObjects\Abstracts\Integers\AbstractInteger; include 'vendor/autoload.php'; // Implement concrete class for as value object class MyObject extends AbstractInteger {} $myObject = MyObject::fromInteger(1337); var_dump($myObject->getValue()); // int(1337)
Other types that are offered:
- NegativeInteger.
- Validates value is below 0 (zero).
- PositiveInteger
- Validates value is above 0 (zero).
- RangedInteger.
- Validates value is higher than minimum.
- Validates value is lower than maximum.
- By default minimum value is
PHP_INT_MINand maximum valuePHP_INT_MAX.
- Octal.
- Validates value is octal.
String type (ByteArray)
Strings are called ByteArrays due to string being a reserved word in PHP.
<?php declare(strict_types=1); use Hyperized\ValueObjects\Abstracts\Strings\AbstractByteArray; include 'vendor/autoload.php'; class MyObject extends AbstractByteArray {} $myObject = MyObject::fromString('Hello world!'); var_dump($myObject->getValue()); // string('Hello world');
Other types that are offered:
- EmptyByteArray.
- Validates value equals '' (empty string)
- NonEmptyByteArray.
- Validates value does not equal '' (empty string)
Licence
MIT
Author
Gerben Geijteman gerben@hyperized.net
统计信息
- 总下载量: 8.15k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 6
- 点击次数: 0
- 依赖项目数: 4
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-02-11