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
$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'
Aleksandr Zelenin, e-mail: aleksandr@zelenin.me