zelenin / hydrator
Object hydrator
0.0.2
2017-06-22 13:30 UTC
Requires
- php: >=7.0
Requires (Dev)
- phpunit/phpunit: ~6.0
- satooshi/php-coveralls: ~1.0.0
This package is not auto-updated.
Last update: 2024-12-22 04:17:07 UTC
README
Installation
Composer
The preferred way to install this extension is through Composer.
Either run
php composer.phar require zelenin/hydrator "~0.0.1"
or add
"zelenin/hydrator": "~0.0.1"
to the require section of your composer.json
Usage
Example
$entity = new Entity(5, 'Title'); $hydrator = new StrategyHydrator(new ReflectionStrategy(), new RawNamingStrategy()); $data = $hydrator->extract($entity); // $data = ['id' => 5, 'name' => 'Title'] $data = ['id' => 10, 'name' => 'New title']; $newEntity = $hydrator->hydrate($entity, $data); // $newEntity->getId() = 10, $newEntity->getName() = 'New title'
Author
Aleksandr Zelenin, e-mail: aleksandr@zelenin.me