Conditions | 3 |
Paths | 3 |
Total Lines | 18 |
Lines | 0 |
Ratio | 0 % |
Tests | 6 |
CRAP Score | 3.576 |
Changes | 0 |
1 | <?php |
||
17 | 19 | public static function getDateTime($value) : DateTimeInterface |
|
18 | { |
||
19 | 19 | $datetime = parent::getDateTime($value); |
|
20 | |||
21 | 14 | if ($datetime instanceof DateTimeImmutable) { |
|
22 | 4 | return $datetime; |
|
23 | } |
||
24 | |||
25 | 12 | if ($datetime instanceof DateTime) { |
|
26 | 12 | return DateTimeImmutable::createFromMutable($datetime); |
|
27 | } |
||
28 | |||
29 | throw new RuntimeException(sprintf( |
||
30 | '%s::getDateTime has returned an unsupported implementation of DateTimeInterface: %s', |
||
31 | parent::class, |
||
32 | get_class($datetime) |
||
33 | )); |
||
34 | } |
||
35 | } |
||
36 |