| Conditions | 5 |
| Paths | 5 |
| Total Lines | 16 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 11 |
| CRAP Score | 5 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 30 | 62 | public static function assertTemplateName(string $value, string $message = ''): void |
|
| 31 | { |
||
| 32 | 62 | if (basename($value) !== $value) { |
|
| 33 | 16 | $format = '' === $message ? '%1$s contains path information (\'/\', \'.\', or \'..\')' : $message; |
|
| 34 | 16 | $message = sprintf($format, self::valueToString($value)); |
|
| 35 | 16 | throw new InvalidArgumentException($message); |
|
| 36 | } |
||
| 37 | |||
| 38 | 46 | $extension = pathinfo($value, PATHINFO_EXTENSION); |
|
| 39 | |||
| 40 | try { |
||
| 41 | 46 | self::assertTemplateFormat(/** @scrutinizer ignore-type */ $extension); |
|
| 42 | 10 | } catch (InvalidArgumentException) { |
|
| 43 | 10 | $format = '' === $message ? '%1$s contains an unsupported file extension' : $message; |
|
| 44 | 10 | $message = sprintf($format, self::valueToString($value)); |
|
| 45 | 10 | throw new InvalidArgumentException($message); |
|
| 46 | } |
||
| 49 |