Conditions | 5 |
Paths | 4 |
Total Lines | 17 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Tests | 5 |
CRAP Score | 8.125 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
18 | 2 | protected static function parseDate($date): Carbon |
|
19 | { |
||
20 | 2 | if ($date instanceof Carbon) { |
|
21 | return $date; |
||
22 | } |
||
23 | |||
24 | 2 | if (is_string($date)) { |
|
25 | return Carbon::parse($date); |
||
26 | } |
||
27 | |||
28 | 2 | if (is_null($date)) { |
|
29 | 2 | return Carbon::today(); |
|
30 | } |
||
31 | |||
32 | throw new InvalidArgumentException(sprintf( |
||
33 | 'Parameter $date must be a string or %s instance. %s given.', |
||
34 | Carbon::class, is_object($date) ? get_class($date) : gettype($date) |
||
35 | )); |
||
38 |