| Conditions | 2 |
| Paths | 2 |
| Total Lines | 17 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 41 | public function __invoke(Request $request, Response $response, callable $next = null) |
||
| 42 | { |
||
| 43 | $action = $request->getAttribute('action', 'index'); |
||
| 44 | |||
| 45 | if (!method_exists($this, $action)) { |
||
| 46 | // clone new response with 404 status code set |
||
| 47 | $response = $response->withStatus(404); |
||
| 48 | |||
| 49 | return $next($request, $response, new \Exception("Function '$action' is not defined!", 404)); |
||
| 50 | } |
||
| 51 | |||
| 52 | $this->request = $request; |
||
| 53 | $this->response = $response; |
||
| 54 | $this->next = $next; |
||
| 55 | |||
| 56 | return $this->$action(); |
||
| 57 | } |
||
| 58 | } |
||
| 59 |