Conditions | 5 |
Paths | 7 |
Total Lines | 15 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 5 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
23 | 3 | public static function toCarbon($dateTime = null, $default = false) |
|
24 | { |
||
25 | 3 | if ($dateTime instanceof Carbon) { |
|
26 | 3 | return $dateTime; |
|
27 | } |
||
28 | 3 | $default = empty($default) ? Carbon::now() : $default; |
|
29 | 3 | if (strtotime($dateTime) > 0) { |
|
30 | 3 | return Carbon::parse($dateTime); |
|
31 | } |
||
32 | |||
33 | 3 | if (is_numeric($dateTime)) { |
|
34 | 3 | return Carbon::createFromTimestamp($dateTime); |
|
35 | } |
||
36 | |||
37 | 3 | return $default; |
|
38 | } |
||
59 |