PageRender   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 50
ccs 0
cts 14
cp 0
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
B renderPage() 0 34 2
1
<?php
2
3
namespace Alvo\Page;
4
5
use \Anax\DI\InjectionAwareInterface;
6
use \Anax\DI\InjectionAwareTrait;
7
use \Anax\Page\PageRenderInterface;
8
9
/**
10
 * A default page rendering class.
11
 */
12
class PageRender implements PageRenderInterface, InjectionAwareInterface
13
{
14
    use InjectionAwareTrait;
15
16
17
18
    /**
19
     * Render a standard web page using a specific layout.
20
     *
21
     * @param array   $data   variables to expose to layout view.
22
     * @param integer $status code to use when delivering the result.
23
     *
24
     * @return void
25
     *
26
     * @SuppressWarnings("exit")
27
     */
28
    public function renderPage($data = [], $status = 200)
29
    {
30
        $data["stylesheets"] = [
31
            "https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css",
32
            "lib/css/font-awesome.min.css",
33
            "https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.css",
34
            "css/style.css",
35
        ];
36
37
        $data["title"] = isset($data["title"]) ? "Anax | " . $data["title"] : "Anax";
0 ignored issues
show
Bug introduced by
Are you sure $data['title'] of type mixed|array<integer,string> can be used in concatenation? ( Ignorable by Annotation )

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

37
        $data["title"] = isset($data["title"]) ? "Anax | " . /** @scrutinizer ignore-type */ $data["title"] : "Anax";
Loading history...
38
39
        $data["scripts"] = [
40
            "https://code.jquery.com/jquery-3.2.1.slim.min.js",
41
            "https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.11.0/umd/popper.min.js",
42
            "https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/js/bootstrap.min.js",
43
            "https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.js",
44
        ];
45
46
        // Add common header, navbar and footer
47
        // $this->view->add("common/header", [], "header");
48
        $view = $this->di->get("view");
49
        // $user = $this->di->get("session")->get('user', null);
50
        $user = $this->di->get("user")->getUser();
51
        $userId = $this->di->get("session")->get('userId', null);
52
53
        $view->add("common/navbar", ["user" => $user, "userId" => $userId], "navbar");
54
        $view->add("common/footer", [], "footer");
55
56
        // Add layout, render it, add to response and send.
57
        $view->add("layout/layout", $data, "layout");
58
        $body = $view->renderBuffered("layout");
59
        $this->di->get("response")->setBody($body)
60
                       ->send($status);
61
        exit;
62
    }
63
}
64