Conditions | 3 |
Paths | 4 |
Total Lines | 23 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Changes | 3 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
29 | public function resolve() |
||
30 | { |
||
31 | $path = $this->request->getPath(); |
||
32 | $method = $this->request->getMethod(); |
||
33 | |||
34 | $callback = $this->routes[$method][$path] ?? false; |
||
35 | |||
36 | if ($callback === false) { |
||
37 | $this->response->setStatusCode(404); |
||
38 | $callback = $this->routes['get']['404'] ?? '404 Not Found'; |
||
39 | } |
||
40 | |||
41 | if (is_string($callback)) { |
||
42 | return $callback; |
||
43 | } |
||
44 | |||
45 | $controllerName = ucfirst(array_shift($callback)) . 'Controller'; |
||
46 | include ROOT_DIR . "/app/controllers/$controllerName.php"; |
||
47 | $controller = new $controllerName; |
||
48 | |||
49 | $method = array_shift($callback); |
||
50 | |||
51 | return $controller->$method(); |
||
52 | } |
||
54 |