mirror of
https://github.com/danog/Valinor.git
synced 2024-11-26 20:24:40 +01:00
f232cc0636
A new constructor can be registered to declare which format(s) are supported during the mapping of a date object. By default, any valid timestamp or ATOM-formatted value will be accepted. ```php (new \CuyZ\Valinor\MapperBuilder()) // Both COOKIE and ATOM formats will be accepted ->registerConstructor( new \CuyZ\Valinor\Mapper\Object\DateTimeFormatConstructor(DATE_COOKIE, DATE_ATOM) ) ->mapper() ->map(DateTimeInterface::class, 'Monday, 08-Nov-1971 13:37:42 UTC'); ``` The previously very opinionated behaviour has been removed, but can be temporarily used to help with the migration. ```php (new \CuyZ\Valinor\MapperBuilder()) ->registerConstructor( new \CuyZ\Valinor\Mapper\Object\BackwardCompatibilityDateTimeConstructor() ) ->mapper() ->map(DateTimeInterface::class, 'Monday, 08-Nov-1971 13:37:42 UTC'); ``` |
||
---|---|---|
.github | ||
docs | ||
qa | ||
src | ||
tests | ||
.changelog | ||
.gitattributes | ||
.gitignore | ||
.php-cs-fixer.dist.php | ||
composer.json | ||
composer.lock | ||
infection.json.dist | ||
LICENSE.md | ||
phpstan.neon.dist | ||
phpunit.xml.dist | ||
psalm.xml | ||
README.md | ||
rector.php |
Valinor • PHP object mapper with strong type support
Valinor is a PHP library that helps to map any input into a strongly-typed value object structure.
The conversion can handle native PHP types as well as other well-known advanced type annotations like array shapes, generics and more.
Installation
composer require cuyz/valinor
Documentation
Documentation can be found at valinor.cuyz.io.
Credits & thank you
The development of this library is mainly motivated by the kind words and the help of many people. I am grateful to everyone, especially to the contributors of this repository who directly help to push the project forward.
I also want to thank Blackfire for providing a license of their awesome tool, leading to notable performance gains when using this library.