Conditions | 4 |
Paths | 6 |
Total Lines | 15 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Tests | 11 |
CRAP Score | 4 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
15 | 4 | public function handle(ParsedRoute $route) |
|
16 | { |
||
17 | 4 | $segments = explode("::", $route->controller()); |
|
18 | 4 | $controller = $segments[0]; |
|
19 | 4 | $action = count($segments) > 1 ? $segments[1] : "index"; |
|
20 | 4 | if (method_exists($controller, $action)) { |
|
21 | 3 | $params = []; |
|
22 | 3 | if (count($route->params())) { |
|
23 | 1 | $params[] = $route->params(); |
|
24 | 1 | } |
|
25 | 3 | return call_user_func_array([new $controller, $action], $params); |
|
26 | } else { |
||
27 | 1 | throw new RuntimeException("No method {$action} in controller {$segments[0]}"); |
|
28 | } |
||
29 | } |
||
30 | } |
||
31 |