| Conditions | 3 |
| Paths | 2 |
| Total Lines | 15 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 21 | public function makeRegExp(string $path): string |
||
| 22 | { |
||
| 23 | $regexp = $path; |
||
| 24 | $placeholders = []; |
||
| 25 | |||
| 26 | if (preg_match_all('~{(.*)}~Uu', $regexp, $placeholders)) { |
||
| 27 | foreach ($placeholders[0] as $index => $match) { |
||
| 28 | $name = $placeholders[1][$index]; |
||
| 29 | $replace = '[^\/]+'; |
||
| 30 | $replace = '(?<'.$name.'>' . $replace . ')'; |
||
| 31 | $regexp = str_replace($match, $replace, $regexp); |
||
| 32 | } |
||
| 33 | } |
||
| 34 | |||
| 35 | return $regexp; |
||
| 36 | } |
||
| 38 |