zelenin / hydrator
Object hydrator
Installs: 138
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 2
Forks: 0
Open Issues: 0
pkg:composer/zelenin/hydrator
Requires
- php: >=7.0
Requires (Dev)
- phpunit/phpunit: ~6.0
- satooshi/php-coveralls: ~1.0.0
This package is not auto-updated.
Last update: 2025-03-30 05:42:13 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