Skip to content

zelenin/hydrator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hydrator Build Status Coverage Status

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: [email protected]