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