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