aeviiq/value-object
最新稳定版本:v1.0.1
Composer 安装命令:
composer require aeviiq/value-object
包简介
A library that provides strict value objects in PHP.
关键字:
README 文档
README
Why
To provide an easy way to create value objects in PHP. Validation can be done by using the Symfony Validator component (https://github.com/symfony/validator and its documentation https://symfony.com/doc/current/validation.html#constraints). This also allows for easy integration with the Symfony Form component, as the value object constraints are defined statically.
Installation
composer require aeviiq/value-object
Declaration
<?php declare(strict_types=1); namespace Aeviiq\ValueObject\Value; use Aeviiq\ValueObject\AbstractString; use Aeviiq\ValueObject\Normalizer; use Symfony\Component\Validator\Constraints; final class Iban extends AbstractString { public static function getConstraints(): array { return [ new Constraints\Iban(), ]; } protected function normalize($value): string { return Normalizer::removeWhitespace($value); } }
Usage
$iban = new Iban('Invalid value'); // Results in InvalidArgumentException $iban = new Iban('NL91 ABNA 0417 1643 00'); // Contains a valid Iban.
统计信息
- 总下载量: 19.01k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-02-17