Conditions | 6 |
Paths | 5 |
Total Lines | 20 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 42 |
Changes | 0 |
1 | <?php |
||
15 | public function dateFormat($date) |
||
16 | { |
||
17 | if (preg_match('/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$/', $date)) { |
||
18 | return $date; |
||
19 | } |
||
20 | |||
21 | if ($date instanceof Carbon || $date instanceof \DateTime) { |
||
22 | return $date->format('Y-m-d'); |
||
23 | } |
||
24 | |||
25 | // sqlite |
||
26 | if ($carbonDate = \DateTime::createFromFormat('Y-m-d H:i:s', $date)) { |
||
27 | return $carbonDate->format('Y-m-d'); |
||
28 | } |
||
29 | |||
30 | // JPAS |
||
31 | if ($carbonDate = \DateTime::createFromFormat('n/j/Y G:i', $date)) { |
||
32 | return $carbonDate->format('Y-m-d'); |
||
33 | } |
||
34 | } |
||
35 | } |
||
36 |