Conditions | 3 |
Paths | 3 |
Total Lines | 12 |
Code Lines | 5 |
Lines | 0 |
Ratio | 0 % |
Tests | 6 |
CRAP Score | 3 |
Changes | 0 |
1 | <?php |
||
33 | public static function toDatetime($date): \DateTime |
||
34 | { |
||
35 | // DateTime |
||
36 | if ($date instanceof \DateTime) { |
||
37 | return $date; |
||
38 | } |
||
39 | // timestamp or 'AAAA-MM-DD' |
||
40 | if (is_numeric($date)) { |
||
41 | return (new \DateTime())->setTimestamp($date); |
||
42 | } |
||
43 | // string (ie: '01/01/2019', 'today') |
||
44 | return new \DateTime($date); |
||
45 | } |
||
47 |