| Conditions | 4 |
| Paths | 4 |
| Total Lines | 24 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 12 |
| CRAP Score | 4.0072 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 44 | 10 | private function resolveParams(Route $route, $url) |
|
| 45 | { |
||
| 46 | 10 | preg_match_all('#' . $route->getPregPattern() . '#', $url, $values, PREG_SET_ORDER); |
|
| 47 | |||
| 48 | // If nothing found |
||
| 49 | 10 | if (count($values) === 0) { |
|
| 50 | 8 | return false; |
|
| 51 | } |
||
| 52 | |||
| 53 | // Remove full match from matches (leave only part matches) |
||
| 54 | 8 | $values = $values[0]; |
|
| 55 | 8 | array_shift($values); |
|
| 56 | |||
| 57 | 8 | $result = []; |
|
| 58 | 8 | foreach ($route->getParams() as $key => $param) { |
|
| 59 | // If parameter key is not set in matched values, route not match and return false |
||
| 60 | 8 | if (!isset($values[$key])) { |
|
| 61 | return false; |
||
| 62 | } |
||
| 63 | 8 | $result[$param] = $values[$key]; |
|
| 64 | 4 | } |
|
| 65 | |||
| 66 | 8 | return $result; |
|
| 67 | } |
||
| 68 | } |
||
| 69 |