Hydrator
namespace: Meow\Hydrator
Library that can hydrate (fill object with data from array) and extract data from object back to array.
Installation
To install this library into your project use composer script:
composer require meow/hydrator
Usage
Hydrate
Filling object from array
protected array $testModelData = [
"name" => "May",
'email' => '[email protected]'
];
// ...
$hydrator = new Hydrator();
$testModel = $hydrator->hydrate(TestModel::class, $this->testModelData);
Extract
Extraction properties and their values back to the array.
$testModelDataArray = $hydrator->extract($testModel, ['name', 'email']);
License: MIT