endeavors / support-vo
一种灵活的方法来处理值对象的数据类型。电子邮件地址作为值对象和电子邮件地址验证。
2.3.2
2018-04-16 23:21 UTC
Requires
- marc-mabe/php-enum: ^2.3
Requires (Dev)
- orchestra/testbench: 3.2.*
- phpunit/phpunit: ~4.8|~5.0
This package is not auto-updated.
Last update: 2024-09-18 02:13:48 UTC
README
一个库,旨在在处理PHP中的原始类型时采用面向对象的方法。
安装
composer require endeavors/support-vo
用法
使用此包相对简单。只需创建值对象,即可开始使用。大多数值对象都提供了工厂创建方式
SomeClass::create('somevalue');
分配给值对象的值将被验证。
电子邮件地址值对象
use Endeavors\Support\VO\EmailAddress; // is valid EmailAddress::create('bob@email.com'); // will throw an exception EmailAddress::create('somevalue');
日期值对象
use Endeavors\Support\VO\Time\Day; // is valid Day::fromSeconds(60 * 60 * 24); // will throw an exception Day::fromSeconds("an invalid second");
待办事项
- 支持更多内置字符串函数,例如 trim、rtrim
- 支持电子邮件之外的具体对象,例如电话、州或国家
- 确定 ModernString 中位置方法的表现
- 添加更全面的文档