Conditions | 2 |
Paths | 2 |
Total Lines | 36 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 6 |
Changes | 0 |
1 | <?php |
||
25 | public function catchAll() |
||
26 | { |
||
27 | $title = " | Anax"; |
||
28 | $pages = [ |
||
29 | "403" => [ |
||
30 | "Anax 403: Forbidden", |
||
31 | "You are not permitted to do this." |
||
32 | ], |
||
33 | "404" => [ |
||
34 | "Anax 404: Not Found", |
||
35 | "The page you are looking for is not here." |
||
36 | ], |
||
37 | "500" => [ |
||
38 | "Anax 500: Internal Server Error", |
||
39 | "An unexpected condition was encountered." |
||
40 | ], |
||
41 | ]; |
||
42 | |||
43 | $path = $this->di->get("router")->getMatchedPath(); |
||
44 | if (!array_key_exists($path, $pages)) { |
||
45 | throw new NotFoundException("Internal route for '$path' is not found."); |
||
46 | } |
||
47 | |||
48 | $page = $this->di->get("page"); |
||
49 | $page->add( |
||
50 | "anax/v2/error/default", |
||
51 | [ |
||
52 | "header" => $pages[$path][0], |
||
53 | "text" => $pages[$path][1], |
||
54 | ] |
||
55 | ); |
||
56 | |||
57 | return $page->render([ |
||
58 | "title" => $pages[$path][0] . $title |
||
59 | ], $path); |
||
60 | } |
||
61 | } |
||
62 |