antiphp/hydrator

Hydrate and extract

1.0.0 2018-10-14 11:50 UTC

This package is auto-updated.

Last update: 2024-04-19 09:19:23 UTC


README

In need of an easy and fast hydrator I had issues with the most common hydrators so I build my own. No dependencies - only if you want to.

Build Status

Hydrate

$hydrator = new SetGetHydrator();
$object = $hydrator->hydrate(['foo_bar' => 123], new Object());
echo $object->getFooBar(); // 123

Considering Object to have setFooBar($value) and getFooBar()

Extract

$object = new Object();
$object->setFooBar(123);

$hydrator = new SetGetHydrator();
$data = $hydrator->extract($object);

echo $data['foo_bar']; // 123

Why not ...

zendframework/zend-hydrate

This package's ClassMethods hydrator requires zendframework/zend-filter which requires zendframework/zend-servicemanager which is annoying overhead.

ocramius/generated-hydrator

This package requires nikic/php-parser in an older version which is not compatible to phpstan/phpstan:^0.10.*. I don't want to be blocked by dependencies.

samdark/hydrator

This package requires me to define a property mapping which I don't want to define.

sylius-labs/association-hydrator

You know, Doctrine.