| Conditions | 2 |
| Paths | 2 |
| Total Lines | 19 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 16 | public static function createFromFormat(string $format, string $date): \DateTime |
||
| 17 | { |
||
| 18 | if ($dateTime = \DateTime::createFromFormat($format, $date)) { |
||
| 19 | $dateTime->setTime(0, 0, 0); |
||
| 20 | return $dateTime; |
||
| 21 | } |
||
| 22 | |||
| 23 | $errors = \DateTime::getLastErrors(); |
||
| 24 | |||
| 25 | $msg = trim( |
||
| 26 | implode( |
||
| 27 | ', ', |
||
| 28 | // @phpstan-ignore-next-line |
||
| 29 | array_merge((array)($errors['errors'] ?? []), (array)($errors['warnings'] ?? [])) |
||
| 30 | ) |
||
| 31 | ); |
||
| 32 | |||
| 33 | throw new InvalidDateStructureException($msg); |
||
| 34 | } |
||
| 35 | } |
||
| 36 |