| Conditions | 3 |
| Paths | 4 |
| Total Lines | 13 |
| Code Lines | 7 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 4 |
| CRAP Score | 3.3332 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 14 | public function decode(string $date): DateTimeImmutable |
||
| 15 | { |
||
| 16 | if ($this->format === null) { |
||
| 17 | 30 | $result = new DateTimeImmutable($date); |
|
| 18 | } else { |
||
| 19 | 30 | $result = DateTimeImmutable::createFromFormat($this->format, $date); |
|
| 20 | 30 | } |
|
| 21 | |||
| 22 | if ($result === false) { |
||
|
|
|||
| 23 | throw new InvalidArgumentException("Cannot decode date {$date}"); |
||
| 24 | } |
||
| 25 | 30 | ||
| 26 | return $result; |
||
| 27 | } |
||
| 37 |