dev-master
9999999-devLibrary of abstract classes intended to be used as bases for value objects.
The Development Requires
by Jakub Giminski
Wallogit.com
2017 © Pedro Peláez
Library of abstract classes intended to be used as bases for value objects.
This library is useful for building value objects in php. It is a collection of abstract classes (each for every scalar type), that contain common validation mechanisms, so you don't have to write them., (*1)
So far, we have StringValue and IntegerValue which already satisfy most of the needs.
More scalar representations may be implemented in the future (feel free to contribute)., (*2)
Look here to find some unit tested examples., (*3)
Required PHP version: 7.0.0 or higher, (*4)
composer require jakubgiminski/value-object
Every ValueObject has a getValue() method., (*5)
Validation rules (optional):, (*6)
/** @var int */ protected $minLength; /** @var int */ protected $maxLength; /** @var array */ protected $validValues = [];
Comparison methods:, (*7)
public function isEqual(StringValueInterface $stringValue): bool; public function isShorterThan(StringValueInterface $stringValue): bool; public function isLongerThan(StringValueInterface $stringValue): bool;
Examples of usage: - Season - Password, (*8)
Validation rules (optional):, (*9)
/** @var array */ protected $validRange = []; /** @var array */ protected $validValues = []; /** @var array */ protected $invalidValues = [];
Comparison methods:, (*10)
public function isEqual(IntegerValueInterface $integerValue): bool; public function isLessThan(IntegerValueInterface $integerValue): bool; public function isGreaterThan(IntegerValueInterface $integerValue): bool;
Examples of usage: - Age - TheatreSeat, (*11)
Library of abstract classes intended to be used as bases for value objects.