| Conditions | 1 |
| Paths | 1 |
| Total Lines | 15 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 10 |
| CRAP Score | 1 |
| Changes | 0 | ||
| 1 | <?php |
||
| 47 | 6 | private function createRegex(RouteDefinition $route): string |
|
| 48 | { |
||
| 49 | 6 | $regex = $route->getPathRegex(); |
|
| 50 | 6 | $reqs = $route->getRequirements(); |
|
| 51 | 6 | $regex = preg_replace_callback( |
|
| 52 | 6 | '/{(\w+)}/', |
|
| 53 | function ($matches) use ($reqs) { |
||
| 54 | 4 | $req = $reqs[$matches[1]] ?? '.+'; |
|
| 55 | |||
| 56 | 4 | return "(?<{$matches[1]}>{$req})"; |
|
| 57 | 6 | }, |
|
| 58 | 6 | $regex |
|
| 59 | ); |
||
| 60 | |||
| 61 | 6 | return $regex; |
|
| 62 | } |
||
| 64 |