Conditions | 2 |
Paths | 2 |
Total Lines | 8 |
Code Lines | 2 |
Lines | 0 |
Ratio | 0 % |
Tests | 3 |
CRAP Score | 2 |
Changes | 0 |
1 | <?php |
||
31 | 27 | private function assertRegex(string $pattern): void |
|
32 | { |
||
33 | /* |
||
34 | * The only sane way to validate a regexp is to execute it. |
||
35 | * Possible warnings or notices are suppressed. |
||
36 | */ |
||
37 | 27 | if (false === @preg_match($pattern, '')) { |
|
38 | 9 | throw new InvalidArgumentException(sprintf('Invalid regular expression received: `%s`, preg error #%d', $pattern, preg_last_error())); |
|
39 | } |
||
42 |