Passed
Push — master ( a471f6...507714 )
by Mikael
01:51
created

App::redirect()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 5
ccs 0
cts 3
cp 0
crap 2
rs 9.4285
1
<?php
2
3
namespace Anax\App;
4
5
/**
6
 * An App class to wrap the resources of the framework.
7
 *
8
 * @SuppressWarnings(PHPMD.ExitExpression)
9
 */
10
class App
11
{
12
    public function redirect($url)
13
    {
14
        $this->response->redirect($this->url->create($url));
0 ignored issues
show
Bug introduced by
The property response does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
Bug introduced by
The property url does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
15
        exit;
16
    }
17
18
19
20
    /**
21
     * Render a standard web page using a specific layout.
22
     */
23
    public function renderPage($data, $status = 200)
24
    {
25
        $data["stylesheets"] = ["css/style.css"];
26
27
        // Add common header, navbar and footer
28
        //$this->view->add("default1/header", [], "header");
29
        //$this->view->add("default1/navbar", [], "navbar");
30
        //$this->view->add("default1/footer", [], "footer");
31
32
        // Add layout, render it, add to response and send.
33
        $this->view->add("default1/layout", $data, "layout");
0 ignored issues
show
Bug introduced by
The property view does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
34
        $body = $this->view->renderBuffered("layout");
35
        $this->response->setBody($body)
36
                       ->send($status);
37
        exit;
38
    }
39
}
40