| Total Complexity | 6 |
| Total Lines | 33 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 9 | abstract class AbstractEntity |
||
| 10 | { |
||
| 11 | public function hydrate(array $data) |
||
| 15 | } |
||
| 16 | |||
| 17 | public function extract() : array |
||
| 18 | { |
||
| 19 | $hydrator = $this->getHydrator(); |
||
| 20 | return $hydrator->extract($this); |
||
| 21 | } |
||
| 22 | |||
| 23 | protected function getDateTimeFromJson($val = null) : ?DateTimeImmutable |
||
| 24 | { |
||
| 25 | if(!$val) { |
||
| 26 | return null; |
||
| 27 | } |
||
| 28 | |||
| 29 | if($val instanceof DateTimeImmutable) { |
||
| 30 | return $val; |
||
| 31 | } |
||
| 32 | |||
| 33 | return DateTimeImmutable::createFromJson($val); |
||
| 34 | } |
||
| 35 | |||
| 36 | /** |
||
| 37 | * @return HydratorInterface |
||
| 38 | */ |
||
| 39 | protected function getHydrator() : HydratorInterface |
||
| 42 | } |
||
| 43 | } |
||
| 44 |