| Conditions | 6 |
| Paths | 6 |
| Total Lines | 27 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 32 | public function getStructuredRoute(String $routerName, $params) |
||
|
|
|||
| 33 | { |
||
| 34 | $params = (array) func_get_arg(1); |
||
| 35 | |||
| 36 | if(!$router = $this->get($routerName)) { |
||
| 37 | return null; |
||
| 38 | } |
||
| 39 | |||
| 40 | $originalRoute = $router->getOriginalRoute(); |
||
| 41 | |||
| 42 | preg_match_all("/{\w+\??}/", $originalRoute, $matches); |
||
| 43 | |||
| 44 | if(empty($matches[0])) { |
||
| 45 | return $originalRoute; |
||
| 46 | } |
||
| 47 | |||
| 48 | if(count($matches[0]) != count($params)) { |
||
| 49 | return null; |
||
| 50 | } |
||
| 51 | |||
| 52 | foreach($matches[0] as $index => $match) { |
||
| 53 | $paramForReplace = isset($params[$index]) ? $params[$index] : 'undefined'; |
||
| 54 | |||
| 55 | $originalRoute = str_replace($match, $paramForReplace, $originalRoute); |
||
| 56 | } |
||
| 57 | |||
| 58 | return $originalRoute; |
||
| 59 | } |
||
| 71 | } |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.