for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* @copyright (c) 2019 Mendel <[email protected]>
* @license see license.txt
*/
namespace drycart\data;
/**
* Trait for dummy hydrate/dehydrate methods
*
* @author mendel
trait HydratableTrait
{
* Hydrate
* @param array $data
* @return HydratableInterface
public static function hydrate(array $data) : HydratableInterface
$model = new static;
foreach($data as $key=>$value) {
$model->$key = $value;
}
return $model;
* Dehydrate
* @return array
public function dehydrate(): array
$data = [];
foreach(GetterHelper::getKeys($this) as $key) {
$data[$key] = $this->$key;
return $data;