endeavors / support-vo
A flexible approach to handle data types as value objects. Email address as a value object and email address validation.
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-12-11 03:20:29 UTC
README
A library designed to take an object oriented approach when working with primitive types in php.
Installation
composer require endeavors/support-vo
Usage
Using this package is fairly straightforward. Simply create the value object and you are ready to go. Most of the value objects offer a factory creation:
SomeClass::create('somevalue');
The value given to the value object is validated.
An email address value object:
use Endeavors\Support\VO\EmailAddress; // is valid EmailAddress::create('bob@email.com'); // will throw an exception EmailAddress::create('somevalue');
A day value object:
use Endeavors\Support\VO\Time\Day; // is valid Day::fromSeconds(60 * 60 * 24); // will throw an exception Day::fromSeconds("an invalid second");
to-do
- Support more built-in string functions e.g. trim, rtrim
- Support specific objects other than email such as phone, state, or country
- Determine performance of position method in ModernString
- Add more comprehensive documentation