| Conditions | 1 |
| Paths | 1 |
| Total Lines | 15 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 6 |
| CRAP Score | 1 |
| Changes | 0 | ||
| 1 | <?php |
||
| 47 | function fnmatch_extended($pattern, $path) |
||
| 48 | { |
||
| 49 | 24 | $quoted = preg_quote($pattern, '~'); |
|
| 50 | |||
| 51 | 24 | $step1 = strtr($quoted, ['\?' => '[^/]', '\*' => '[^/]*', '/\*\*' => '(?:/.*)?', '#' => '\d+', '\[' => '[', |
|
| 52 | '\]' => ']', '\-' => '-', '\{' => '{', '\}' => '}']); |
||
| 53 | |||
| 54 | $step2 = preg_replace_callback('~{[^}]+}~', function ($part) { |
||
| 55 | 4 | return '(?:' . substr(strtr($part[0], ',', '|'), 1, -1) . ')'; |
|
| 56 | 24 | }, $step1); |
|
| 57 | |||
| 58 | 24 | $regex = rawurldecode($step2); |
|
| 59 | |||
| 60 | 24 | return (boolean)preg_match("~^{$regex}$~", $path); |
|
| 61 | } |
||
| 62 | |||
| 63 |