| Conditions | 5 | 
| Paths | 12 | 
| Total Lines | 20 | 
| Code Lines | 15 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Tests | 16 | 
| CRAP Score | 5 | 
| Changes | 1 | ||
| Bugs | 0 | Features | 0 | 
| 1 | <?php | ||
| 15 | 5 | public function handle(ParsedRoute $route) | |
| 16 |     { | ||
| 17 | 5 | $controller = $route->controller(); | |
| 18 | 5 | $rawParams = $route->params(); | |
| 19 | 5 |         foreach ($rawParams as $param => $value) { | |
| 20 | 2 |             if (strpos($controller, "{".$param."}") !== false) { | |
| 21 | 1 |                 $controller = str_replace("{".$param."}", ucfirst($value), $controller); | |
| 22 | 1 | unset($rawParams[$param]); | |
| 23 | 1 | } | |
| 24 | 5 | } | |
| 25 | 5 |         $segments = explode("::", $controller); | |
| 26 | 5 | $controller = $segments[0]; | |
| 27 | 5 | $action = count($segments) > 1 ? $segments[1] : "index"; | |
| 28 | 5 |         if (method_exists($controller, $action)) { | |
| 29 | 4 | $params = [$rawParams]; | |
| 30 | 4 | return call_user_func_array([new $controller, $action], $params); | |
| 31 |         } else { | ||
| 32 | 1 |             throw new RuntimeException("No method {$action} in controller {$segments[0]}"); | |
| 33 | } | ||
| 34 | } | ||
| 35 | } | ||
| 36 |