File tree Expand file tree Collapse file tree 1 file changed +2
-9
lines changed
Expand file tree Collapse file tree 1 file changed +2
-9
lines changed Original file line number Diff line number Diff line change @@ -268,15 +268,8 @@ public static function fromTimestamp(int $timestamp): self
268268 */
269269 public static function fromDateFormat (string $ format , string $ datetime ): self
270270 {
271- try {
272- $ value = DateTimeImmutable::createFromFormat ($ format , $ datetime );
273- } catch (Exception $ exception ) {
274- throw new SyntaxError ('The date notation ` ' .$ datetime .'` is incompatible with the date format ` ' .$ format .'`. ' , 0 , $ exception );
275- }
276-
277- if (!$ value instanceof DateTimeImmutable) {
278- throw new SyntaxError ('The date notation ` ' .$ datetime .'` is incompatible with the date format ` ' .$ format .'`. ' );
279- }
271+ $ value = DateTimeImmutable::createFromFormat ($ format , $ datetime );
272+ $ value instanceof DateTimeImmutable || throw new SyntaxError ('The date notation ` ' .$ datetime .'` is incompatible with the date format ` ' .$ format .'`. ' );
280273
281274 return new self ($ value );
282275 }
You can’t perform that action at this time.
0 commit comments