| Conditions | 3 |
| Paths | 4 |
| Total Lines | 14 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 15 | public function decode($date) |
||
| 16 | { |
||
| 17 | if ($this->format === null) { |
||
| 18 | $result = new \DateTimeImmutable($date); |
||
| 19 | } else { |
||
| 20 | $result = \DateTimeImmutable::createFromFormat($this->format, $date); |
||
| 21 | } |
||
| 22 | |||
| 23 | if ($result === false) { |
||
| 24 | throw new \InvalidArgumentException("Cannot decode date {$date}"); |
||
| 25 | } |
||
| 26 | |||
| 27 | return $result; |
||
| 28 | } |
||
| 29 | |||
| 41 | } |