PageRender::renderPage()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 16
rs 9.4285
cc 1
eloc 11
nc 1
nop 2
1
<?php
2
3
namespace Anax\Page;
4
5
use \Anax\DI\InjectionAwareInterface;
6
use \Anax\DI\InjectionAwareTrait;
7
8
/**
9
 * A default page rendering class.
10
 */
11
class PageRender implements PageRenderInterface, InjectionAwareInterface
12
{
13
    use InjectionAwareTrait;
14
15
16
    /**
17
     * Render a standard web page using a specific layout.
18
     *
19
     * @param array $data variables to expose to layout view.
20
     * @param integer $status code to use when delivering the result.
21
     *
22
     * @SuppressWarnings(PHPMD.ExitExpression)
23
     * @param string $title
0 ignored issues
show
Bug introduced by
There is no parameter named $title. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
24
     * @return void
25
     */
26
    public function renderPage($data = null, $status = 200)
27
    {
28
        $data["stylesheets"] = ["css/style.min.css"];
29
        $view = $this->di->get("view");
30
        // Add common header, navbar and footer
31
        $view->add("default/header", [], "header");
32
        $view->add("navbar/navbar", [], "navbar");
33
        $view->add("default/footer", [], "footer");
34
35
        // Add layout, render it, add to response and send.
36
        $view->add("default1/layout", $data, "layout");
37
        $body = $view->renderBuffered("layout");
38
        $this->di->get("response")->setBody($body)
39
                                  ->send($status);
40
        exit;
41
    }
42
43
    /**
44
     * Render a standard web page using a specific layout.
45
     *
46
     * @param array $data variables to expose to layout view.
47
     * @param integer $status code to use when delivering the result.
48
     *
49
     * @SuppressWarnings(PHPMD.ExitExpression)
50
     * @param string $title
0 ignored issues
show
Bug introduced by
There is no parameter named $title. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
51
     * @return void
52
     */
53
    public function renderLogin($data = null, $status = 200)
54
    {
55
        $data["stylesheets"] = ["css/style.min.css"];
56
        $view = $this->di->get("view");
57
        // Add common header, navbar and footer
58
        // $view->add("default/header", [], "header");
0 ignored issues
show
Unused Code Comprehensibility introduced by
74% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
59
        // $view->add("navbar/navbar", [], "navbar");
0 ignored issues
show
Unused Code Comprehensibility introduced by
74% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
60
        // $view->add("default/footer", [], "footer");
0 ignored issues
show
Unused Code Comprehensibility introduced by
74% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
61
62
        // Add layout, render it, add to response and send.
63
        $view->add("default1/layout", $data, "layout");
64
        $body = $view->renderBuffered("layout");
65
        $this->di->get("response")->setBody($body)
66
                                  ->send($status);
67
        exit;
68
    }
69
}
70