Total Complexity | 6 |
Total Lines | 41 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
17 | final class SimpleHydrator implements Hydrates |
||
18 | { |
||
19 | private $class; |
||
20 | private $setter; |
||
21 | private $object; |
||
22 | |||
23 | private function __construct( |
||
24 | ReflectionClass $reflector, |
||
25 | Closure $setter = null |
||
26 | ) { |
||
27 | $this->class = $reflector; |
||
28 | $this->setter = $setter ?: function (string $attribute, $value) |
||
29 | { |
||
30 | $this->$attribute = $value; |
||
31 | }; |
||
32 | } |
||
33 | |||
34 | public static function forThe( |
||
35 | string $class, |
||
36 | Closure $setter = null |
||
37 | ) : Hydrates |
||
38 | { |
||
39 | return new SimpleHydrator(new ReflectionClass($class), $setter); |
||
40 | } |
||
41 | |||
42 | public function fromArray(array $data) |
||
52 | } |
||
53 | } |
||
54 | |||
55 | public function currentInstance() |
||
58 | } |
||
59 | } |
||
60 |