kwizer / hydrator
Hydrator
Installs: 12
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/kwizer/hydrator
Requires (Dev)
- phpunit/phpunit: ^7.1
- squizlabs/php_codesniffer: ^3.2
This package is not auto-updated.
Last update: 2025-10-08 01:21:07 UTC
README
A simple hydrator without mapping.
Why
Hydrate an instance simply with a data source.
How
Instantiate the hydrator and call the hydrate method with the object to hydrate and the data source
class MyClass { private $foo; } $myDatas = ['foo' => 'bar']; $hydrator = new \Kwizer\Hydrator\Hydrator(); $myObject = $hydrator->hydrate(MyClass::class, $myDatas);
You can directly hydrate an object already instantiated.
$myObject = new MyClass(); $myObject = $hydrator->hydrate($myObject, $myDatas);
Or hydrate with an object source
$datas = new \stdClass(); $datas->foo = 'bar'; $myObject = $hydrator->hydrate(MyClass::class, $myDatas);
The hyrator uses the with methods and set methods first if presents, then directly the property, breaking accessibility if necessary.
Installation
composer require kwizer/hydrator