| Conditions | 6 |
| Paths | 6 |
| Total Lines | 30 |
| Code Lines | 17 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 15 |
| CRAP Score | 6.0087 |
| Changes | 0 | ||
| 1 | <?php |
||
| 28 | public function match(RouteInterface $route, Request $request): bool |
||
| 29 | { |
||
| 30 | 10 | $pathInfo = $request->getPathInfo(); |
|
| 31 | 10 | $pattern = $route->getPattern(); |
|
| 32 | 10 | if (!$pattern) { |
|
| 33 | 3 | return $pathInfo === $route->getUri(); |
|
| 34 | } |
||
| 35 | |||
| 36 | 8 | $matched = preg_match_all($pattern, $pathInfo, $matches); |
|
| 37 | |||
| 38 | 8 | if (0 === $matched) { |
|
| 39 | 1 | return false; |
|
| 40 | } |
||
| 41 | |||
| 42 | 7 | $i = 0; |
|
| 43 | |||
| 44 | 7 | $parameters = $route->getParameters(); |
|
| 45 | 7 | if (!$parameters) { |
|
| 46 | 1 | return true; |
|
| 47 | } |
||
| 48 | |||
| 49 | 6 | foreach ($parameters as $parameter) { |
|
| 50 | 6 | if (!$parameter) { |
|
| 51 | continue; |
||
| 52 | } |
||
| 53 | |||
| 54 | 6 | $request->request->set($parameter, $matches[++$i][0]); |
|
| 55 | } |
||
| 56 | |||
| 57 | 6 | return true; |
|
| 58 | } |
||
| 60 |