Conditions | 3 |
Paths | 4 |
Total Lines | 12 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Tests | 8 |
CRAP Score | 3 |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
37 | 4 | public function handle(ParsedRoute $route) |
|
38 | { |
||
39 | 4 | $segments = explode("::", $route->controller()); |
|
40 | 4 | $controller = $segments[0]; |
|
41 | 4 | $action = count($segments) > 1 ? $segments[1] : "index"; |
|
42 | 4 | if (method_exists($controller, $action)) { |
|
43 | 3 | $params = [$this->request, $this->response, $route->params()]; |
|
44 | 3 | return call_user_func_array([new $controller(), $action], $params); |
|
45 | } else { |
||
46 | 1 | throw new RuntimeException("No method {$action} in controller {$segments[0]}"); |
|
47 | } |
||
48 | } |
||
49 | } |
||
50 |