| Total Complexity | 7 |
| Total Lines | 38 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 19 | final class ReflectiveHydrator implements Hydrates |
||
| 20 | { |
||
| 21 | private function __construct() |
||
| 22 | { |
||
| 23 | } |
||
| 24 | |||
| 25 | /** |
||
| 26 | * Produce a reflective hydrator. |
||
| 27 | * |
||
| 28 | * @return Hydrates A hydrator that uses reflection to write properties. |
||
| 29 | */ |
||
| 30 | public static function default(): Hydrates |
||
| 31 | { |
||
| 32 | return new ReflectiveHydrator; |
||
| 33 | } |
||
| 34 | |||
| 35 | /** @inheritdoc */ |
||
| 36 | public function writeTo(object $target, array $data): void |
||
| 37 | { |
||
| 38 | $object = new ReflectionObject($target); |
||
| 39 | foreach ($data as $name => $value) { |
||
| 40 | $this->write($object, $target, $name, $value); |
||
| 41 | } |
||
| 42 | } |
||
| 43 | |||
| 44 | private function write( |
||
| 57 | } |
||
| 58 | } |
||
| 59 |