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