Conditions | 4 |
Paths | 6 |
Total Lines | 21 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Tests | 8 |
CRAP Score | 4 |
Changes | 0 |
1 | <?php |
||
37 | 4 | public function normalizeField( |
|
38 | string $path, |
||
39 | $object, |
||
40 | NormalizerContextInterface $context, |
||
41 | NormalizerInterface $normalizer = null |
||
42 | ) { |
||
43 | 4 | $value = $this->fieldNormalizer->normalizeField($path, $object, $context, $normalizer); |
|
44 | |||
45 | 4 | if (is_string($value)) { |
|
46 | try { |
||
47 | 2 | $value = new \DateTime($value); |
|
48 | 1 | } catch (\Exception $exception) { |
|
|
|||
49 | } |
||
50 | } |
||
51 | |||
52 | 4 | if (!$value instanceof \DateTimeInterface) { |
|
53 | 2 | return $value; |
|
54 | } |
||
55 | |||
56 | 2 | return $value->format($this->format); |
|
57 | } |
||
58 | } |
||
59 |