yunasoft/hydrator

Allows to extract data from an object or create a new object based on data for the purpose of persisting state. Works with private and protected properties.

Installs: 108

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

pkg:composer/yunasoft/hydrator

dev-master 2020-05-12 09:33 UTC

This package is auto-updated.

Last update: 2025-09-12 20:50:14 UTC


README

Allows extracting data from objects and getting objects from data

Usage example:

// extract data
(new Hydrator($object))->extract();


//hydrate object
$object = (new Hydrator($source))->hydrateInto($object)

By default Hydrator create map for all source attributes. You can set custom map

// extract data
(new Hydrator($object))->map(['id' => 'id', 'title' => 'title'])->extract();


//hydrate object
$object = (new Hydrator($source))->map(['id' => 'id', 'title' => 'title'])->hydrateInto($object)

Also you can extract and hydrate in strict mode

// extract data
(new Hydrator($object))->extract(true);


//hydrate object
$object = (new Hydrator($source))->hydrateInto($object, true)