Total Complexity | 5 |
Total Lines | 23 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php declare(strict_types=1); |
||
7 | final class Date implements MappingStrategy, DefaultAttributesProvider |
||
8 | { |
||
9 | 6 | public static function hydrate(&$value, array $attributes = []): void |
|
10 | { |
||
11 | 6 | if ($value !== null) { |
|
12 | 2 | $value = new \DateTime($value, new \DateTimeZone($attributes['timezone'])); |
|
13 | } |
||
14 | 6 | } |
|
15 | |||
16 | 3 | public static function extract(&$value, array $attributes = []): void |
|
17 | { |
||
18 | 3 | if ($value instanceof \DateTimeInterface) { |
|
19 | 1 | $value = $value->format($attributes['format']); |
|
20 | } else { |
||
21 | 2 | $value = null; |
|
22 | } |
||
23 | 3 | } |
|
24 | |||
25 | 5 | public static function getDefaultAttributes(): array |
|
30 | ]; |
||
31 | } |
||
32 | } |
||
33 |