ErrorController::page404()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 8
c 0
b 0
f 0
ccs 0
cts 6
cp 0
rs 9.4285
cc 1
eloc 5
nc 1
nop 0
crap 2
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