Conditions | 5 |
Paths | 3 |
Total Lines | 16 |
Code Lines | 7 |
Lines | 0 |
Ratio | 0 % |
Tests | 8 |
CRAP Score | 5 |
Changes | 3 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
34 | 33 | public function deserializeDateTimeFromJson(JsonDeserializationVisitor $visitor, $data, array $type) |
|
35 | { |
||
36 | // Handle empty or invalid date / datetime values. |
||
37 | 33 | if ('' === $data || null === $data || strpos($data, '0000-00-00') !== false) { |
|
38 | 12 | return null; |
|
39 | } |
||
40 | |||
41 | // We want to always show the response in the UTC timezone. |
||
42 | 27 | $dateTime = parent::deserializeDateTimeFromJson($visitor, $data, $type); |
|
43 | |||
44 | 27 | if ($dateTime instanceof \DateTime) { |
|
45 | 27 | $dateTime->setTimezone(new \DateTimeZone('UTC')); |
|
46 | 27 | } |
|
47 | |||
48 | 27 | return $dateTime; |
|
49 | } |
||
50 | } |
||
51 |