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