onemustcode/hydrator

Hydrator to map or extract an extract object

v0.1.1 2017-04-14 11:06 UTC

This package is auto-updated.

Last update: 2024-12-04 22:02:10 UTC


README

Simple to use hydrator to hydrate an object from array or extract an object to an array.

Usage

To install the hydrator use the following command;

composer require onemustcode/hydrator

Hydrating

To hydrate an object you can use the hydrate method;

$object = new Object(); // The object to hydrate
$data = ['some_field' => 'some_value', 'boolean_field' => true];
$object = $hydrator->hydrate($object, $data);

Extracting

To extract an object to an array you can use the extract method;

$array = $hydrator->extract($object);

Todo

  • Add strategies
  • Add unit tests