| Conditions | 7 |
| Paths | 6 |
| Total Lines | 31 |
| Code Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 56 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 16 | public static function containsUrl(string $uri): bool |
||
| 17 | { |
||
| 18 | foreach (self::findAll() as $routes) { |
||
| 19 | foreach ($routes as $route) { |
||
| 20 | $routeMatcher = '/^' . preg_quote('/' . rtrim((string) $route['route']['url'], '/*'), '/') . '/'; |
||
| 21 | |||
| 22 | if (is_array($route['route']['arguments'])) { |
||
| 23 | foreach ($route['route']['arguments'] as $argumentName => $argumentNumber) { |
||
| 24 | $metadataType = $route['route']['metadata']['param'][$argumentNumber]; |
||
| 25 | |||
| 26 | $argumentReplace = '[^\/]+'; |
||
| 27 | |||
| 28 | if ($metadataType['type'] === 'integer') { |
||
| 29 | $argumentReplace = '[\d]+'; |
||
| 30 | } |
||
| 31 | |||
| 32 | $routeMatcher = str_replace( |
||
| 33 | preg_quote('{' . $argumentName . '}', '/'), |
||
| 34 | $argumentReplace, |
||
| 35 | $routeMatcher |
||
| 36 | ); |
||
| 37 | } |
||
| 38 | } |
||
| 39 | |||
| 40 | if (preg_match($routeMatcher, $uri) === 1) { |
||
| 41 | return true; |
||
| 42 | } |
||
| 43 | } |
||
| 44 | } |
||
| 45 | |||
| 46 | return false; |
||
| 47 | } |
||
| 49 |