Conditions | 2 |
Paths | 2 |
Total Lines | 17 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Tests | 10 |
CRAP Score | 2 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
28 | 10 | public static function simplifyRoute(string $route): string |
|
29 | { |
||
30 | 10 | $variables = RouteParser::parseRoute($route); |
|
31 | |||
32 | 10 | $search = []; |
|
33 | 10 | $replace = []; |
|
34 | 10 | foreach ($variables as $variable) { |
|
35 | 3 | $search[] = $variable['statement']; |
|
36 | 3 | $replace[] = '{' . $variable['name'] . '}'; |
|
37 | } |
||
38 | |||
39 | // will be replaced by an empty string: |
||
40 | // https://github.com/php/php-src/blob/a04577fb4ab5e1ebc7779608523b95ddf01e6c7f/ext/standard/string.c#L4406-L4408 |
||
41 | 10 | $search[] = '('; |
|
42 | 10 | $search[] = ')'; |
|
43 | |||
44 | 10 | return str_replace($search, $replace, $route); |
|
45 | } |
||
47 |