ErrorController   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 72
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 72
c 0
b 0
f 0
ccs 0
cts 25
cp 0
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A errorPage() 0 8 1
A page403() 0 8 1
A page404() 0 8 1
A page500() 0 8 1
1
<?php
2
3
// namespace Anax\Page;
4
namespace Marcusgsta\Page;
5
6
use \Anax\DI\InjectionAwareInterface;
7
use \Anax\DI\InjectionAwareTrait;
8
9
/**
10
 * A sample class for routes dealing with error situations.
11
 */
12
class ErrorController implements InjectionAwareInterface
13
{
14
    use InjectionAwareTrait;
15
16
17
18
    /**
19
     * Render an error page with a message and a status code.
20
     *
21
     * @param integer $status   code to use for response.
22
     * @param string  $title    to use for the page.
23
     * @param string  $message  to display in the view.
24
     *
25
     * @return void
26
     */
27
    public function errorPage($status, $title, $message)
28
    {
29
        $this->di->get("view")->add("default1/http_status_code", [
30
            "title" => $title,
31
            "message" => $message,
32
        ]);
33
        $this->di->get("pageRender")->renderPage(["title" => $title], $status);
34
    }
35
36
37
38
    /**
39
     * Render a 403 forbidden page using the default page renderer.
40
     *
41
     * @return void
42
     */
43
    public function page403()
44
    {
45
        $this->errorPage(
46
            403,
47
            "403 Forbidden",
48
            "You are not permitted to do this."
49
        );
50
    }
51
52
53
54
    /**
55
     * Render a 404 Page not found using the default page renderer.
56
     *
57
     * @return void
58
     */
59
    public function page404()
60
    {
61
        $this->errorPage(
62
            404,
63
            "404 Page not found",
64
            "The page you are looking for is not here."
65
        );
66
    }
67
68
69
70
    /**
71
     * Render a 404 Page not found using the default page renderer.
72
     *
73
     * @return void
74
     */
75
    public function page500()
76
    {
77
        $this->errorPage(
78
            500,
79
            "500 Internal Server Error",
80
            "An unexpected condition was encountered."
81
        );
82
    }
83
}
84