Completed
Push — master ( f9ced2...08fe60 )
by Mr
02:20
created

Error::renderHtmlErrorMessage()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 11
nc 1
nop 0
dl 0
loc 14
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace DrMVC\Controllers;
4
5
use \Psr\Http\Message\ServerRequestInterface as Request;
6
use \Psr\Http\Message\ResponseInterface as Response;
7
8
class Error
9
{
10
    public function action_index(Request $request, Response $response, array $args)
0 ignored issues
show
Unused Code introduced by
The parameter $args is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

10
    public function action_index(Request $request, Response $response, /** @scrutinizer ignore-unused */ array $args)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $request is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

10
    public function action_index(/** @scrutinizer ignore-unused */ Request $request, Response $response, array $args)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
11
    {
12
        $body = $this->renderHtmlErrorMessage();
13
        $response->getBody()->write($body);
14
    }
15
16
    /**
17
     * Render HTML error page
18
     *
19
     * @return string
20
     */
21
    protected function renderHtmlErrorMessage()
22
    {
23
        $title = 'DrMVC Application Error';
24
        $html = '<p>A website error has occurred. Sorry for the temporary inconvenience.</p>';
25
        $output = sprintf(
26
            "<html><head><meta http-equiv='Content-Type' content='text/html; charset=utf-8'>" .
27
            "<title>%s</title><style>body{margin:0;padding:30px;font:12px/1.5 Helvetica,Arial,Verdana," .
28
            "sans-serif;}h1{margin:0;font-size:48px;font-weight:normal;line-height:48px;}strong{" .
29
            "display:inline-block;width:65px;}</style></head><body><h1>%s</h1>%s</body></html>",
30
            $title,
31
            $title,
32
            $html
33
        );
34
        return $output;
35
    }
36
}
37