Conditions | 5 |
Paths | 4 |
Total Lines | 20 |
Lines | 0 |
Ratio | 0 % |
Tests | 5 |
CRAP Score | 11.643 |
Changes | 0 |
1 | <?php |
||
26 | 2 | public function transform($value) |
|
27 | { |
||
28 | 2 | if (is_null($value) || empty($value)) { |
|
29 | return null; |
||
30 | } |
||
31 | |||
32 | 2 | if ($value instanceof \DateTime) { |
|
33 | return $value; |
||
34 | } |
||
35 | |||
36 | // check if strtotime matches |
||
37 | 2 | if (false !== strtotime($value)) { |
|
38 | 2 | return new \DateTime($value, $this->timezone); |
|
39 | } |
||
40 | |||
41 | // last resort |
||
42 | $transformer = new FallbackTransformer(); |
||
43 | |||
44 | return $transformer->transform($value); |
||
45 | } |
||
46 | } |
||
47 |