Completed
Push — erdiko2 ( 05bf58...719271 )
by John
03:15
created

Examples::getSession()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 13
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 7
nc 2
nop 3
1
<?php
2
namespace app\controllers;
3
4
class Examples extends \erdiko\controllers\Web
5
{
6
    use \erdiko\theme\traits\Controller; // Add theme engine suport (for convenience)
7
8
    public function get($request, $response, $args)
9
    {
10
        // $this->container->logger->debug("examples");
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% 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...
11
        $view = 'examples/list.html';
12
13
        // Get erdiko config, this gets application.json and loads the theme specified
14
        // $themeData = \erdiko\theme\Config::get();
0 ignored issues
show
Unused Code Comprehensibility introduced by
46% 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...
15
        $themeData['theme'] = \erdiko\theme\Config::get($this->container->get('settings')['theme']);
0 ignored issues
show
Coding Style Comprehensibility introduced by
$themeData was never initialized. Although not strictly required by PHP, it is generally a good practice to add $themeData = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
16
        // $themeData['args'] = $args; // optional
0 ignored issues
show
Unused Code Comprehensibility introduced by
55% 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...
17
18
        $themeData['page'] = [
19
            'title' => "Erdiko Web Example",
20
            'hello' => "world"
21
            ];
22
23
        return $this->container->theme->render($response, $view, $themeData);
24
    }
25
26 View Code Duplication
    public function getOnecolumn($request, $response, $args)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
27
    {
28
        $this->container->logger->debug("route: /config");
29
        $view = 'layouts/1column.html';
30
        $themeData['theme'] = \erdiko\theme\Config::get($this->container->get('settings')['theme']);
0 ignored issues
show
Coding Style Comprehensibility introduced by
$themeData was never initialized. Although not strictly required by PHP, it is generally a good practice to add $themeData = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
31
        $themeData['page']['title'] = "1 Column Layout";
32
33
        return $this->container->theme->render($response, $view, $themeData);
34
    }
35
36 View Code Duplication
    public function getTwocolumn($request, $response, $args)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
37
    {
38
        $this->container->logger->debug("route: /config");
39
        $view = 'layouts/2column.html';
40
        $themeData['theme'] = \erdiko\theme\Config::get($this->container->get('settings')['theme']);
0 ignored issues
show
Coding Style Comprehensibility introduced by
$themeData was never initialized. Although not strictly required by PHP, it is generally a good practice to add $themeData = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
41
        $themeData['page']['title'] = "2 Column Layout";
42
43
        return $this->container->theme->render($response, $view, $themeData);
44
    }
45
46 View Code Duplication
    public function getThreecolumn($request, $response, $args)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
47
    {
48
        $this->container->logger->debug("route: /config");
49
        $view = 'layouts/3column.html';
50
        $themeData['theme'] = \erdiko\theme\Config::get($this->container->get('settings')['theme']);
0 ignored issues
show
Coding Style Comprehensibility introduced by
$themeData was never initialized. Although not strictly required by PHP, it is generally a good practice to add $themeData = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
51
        $themeData['page']['title'] = "3 Column Layout";
52
53
        return $this->container->theme->render($response, $view, $themeData);
54
    }
55
56 View Code Duplication
    public function getJohn($request, $response, $args)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
57
    {
58
        $view = 'pages/example.html';
59
60
        // Get erdiko config, this gets application.json and loads the theme specified
61
        $themeData['theme'] = \erdiko\theme\Config::get($this->container->get('settings')['theme']);
0 ignored issues
show
Coding Style Comprehensibility introduced by
$themeData was never initialized. Although not strictly required by PHP, it is generally a good practice to add $themeData = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
62
        $themeData['args'] = $args; // optional
63
        $themeData['page'] = [
64
            'title' => "Erdiko Web Example"
65
            ];
66
67
        return $this->container->theme->render($response, $view, $themeData);
68
    }
69
70 View Code Duplication
    public function getMarkup($request, $response, $args)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
71
    {
72
        $view = 'examples/markup.html';
73
74
        // Get erdiko config, this gets application.json and loads the theme specified
75
        $themeData['theme'] = \erdiko\theme\Config::get($this->container->get('settings')['theme']);
0 ignored issues
show
Coding Style Comprehensibility introduced by
$themeData was never initialized. Although not strictly required by PHP, it is generally a good practice to add $themeData = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
76
        $themeData['args'] = $args; // optional
77
        $themeData['page'] = [
78
            'title' => "Markup Example"
79
            ];
80
81
        return $this->container->theme->render($response, $view, $themeData);
82
    }
83
84 View Code Duplication
    public function getCarousel($request, $response, $args)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
85
    {
86
        $view = 'examples/carousel.html';
87
88
        // Get erdiko config, this gets application.json and loads the theme specified
89
        $themeData['theme'] = \erdiko\theme\Config::get($this->container->get('settings')['theme']);
0 ignored issues
show
Coding Style Comprehensibility introduced by
$themeData was never initialized. Although not strictly required by PHP, it is generally a good practice to add $themeData = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
90
        $themeData['page'] = [
91
            'title' => "Fullpage Example",
92
            'description' => "This is the description of the page."
93
            ];
94
95
        return $this->container->theme->render($response, $view, $themeData);
96
    }
97
98
    /**
99
     * Leverage the theme trait to easily add content to an action
100
     */
101 View Code Duplication
    public function getTheme($request, $response, $args)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
102
    {
103
        $this->getThemeEngine();
104
        $this->theme->title = "Theme Engine Example";
105
        $this->theme->description = "This page is rendered using the erdiko theme engine.
106
            \\erdiko\\theme\\Engine";
107
108
        return $this->render($response, null, $theme);
0 ignored issues
show
Bug introduced by
The variable $theme does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
109
    }
110
111
    /**
112
     * Alternative way to use the theme Engine (explicit)
113
     * In this approach it does not rely on the theme trait
114
     */
115
    public function getTheme2($request, $response, $args)
116
    {
117
        $theme = new \erdiko\theme\Engine( $this->container->get('settings')['theme'] );
118
        $theme->title = "Theme Engine Example";
119
        $theme->description = "This page is rendered with the erdiko theme engine.
120
            It does not leverage the erdiko theme trait.
121
            \\erdiko\\theme\\Engine";
122
123
        return $this->container->theme->render($response, $theme->getDefaultView(), $theme->toArray());
124
        // return $this->render($response, null, $theme);
0 ignored issues
show
Unused Code Comprehensibility introduced by
69% 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...
125
    }
126
127
    /**
128
     * Leverage the theme trait to easily add content to an action
129
     */
130 View Code Duplication
    public function getAbout($request, $response, $args)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
131
    {
132
        $this->getThemeEngine();
133
        $this->theme->title = "About";
134
        $this->theme->description = "Erdiko is a framework and set of open source packages for lean php development.
135
            Created by Arroyo Labs and community contributors with the help of Slim and Symfony components";
136
137
        return $this->render($response, null, $theme);
0 ignored issues
show
Bug introduced by
The variable $theme does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
138
    }
139
140
    /**
141
     * Test the session
142
     */
143
    public function getSession($request, $response, $args)
0 ignored issues
show
Coding Style introduced by
getSession uses the super-global variable $_GET which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
144
    {
145
        $this->getThemeEngine();
146
        $this->theme->title = "Session Test";
147
148
        $value = (isset($_GET["index"])) ? $_GET["index"] : \erdiko\session\Session::get('index');
0 ignored issues
show
Bug introduced by
The call to get() misses a required argument $expired.

This check looks for function calls that miss required arguments.

Loading history...
149
        \erdiko\session\Session::set('index', $value);
150
151
        // $this->container->logger->debug("session::index = ".\erdiko\session\Session::get('index'));
0 ignored issues
show
Unused Code Comprehensibility introduced by
64% 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...
152
        $this->theme->description = "Session value: ".\erdiko\session\Session::get('index');
0 ignored issues
show
Bug introduced by
The call to get() misses a required argument $expired.

This check looks for function calls that miss required arguments.

Loading history...
153
154
        return $this->render($response, null, $theme);
0 ignored issues
show
Bug introduced by
The variable $theme does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
155
    }
156
157
    public function getFlash($request, $response, $args)
158
    {
159
        $view = 'page.html';
160
161
        // Add some flash messages
162
        $this->container->flash->addMessage('success', 'This is a success message');
163
        $this->container->flash->addMessage('info', 'This is an info message');
164
        $this->container->flash->addMessage('warning', 'This is a warning message');
165
        $this->container->flash->addMessage('danger', 'This is a danger (error) message');
166
167
        // Get erdiko config, this gets application.json and loads the theme specified
168
        $themeData['theme'] = \erdiko\theme\Config::get($this->container->get('settings')['theme']);
0 ignored issues
show
Coding Style Comprehensibility introduced by
$themeData was never initialized. Although not strictly required by PHP, it is generally a good practice to add $themeData = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
169
        $themeData['args'] = $args;
170
        $themeData['page'] = [
171
            'title' => "Flash Message Example"
172
            ];
173
174
        return $this->container->theme->render($response, $view, $themeData);
175
    }
176
177
    public function getGrid($request, $response, $args)
178
    {
179
        $this->container->logger->debug("/controller");
180
        $view = 'examples/grid.html';
181
182
        // Get erdiko config, this gets application.json and loads the theme specified
183
        $themeData['theme'] = \erdiko\theme\Config::get($this->container->get('settings')['theme']);
0 ignored issues
show
Coding Style Comprehensibility introduced by
$themeData was never initialized. Although not strictly required by PHP, it is generally a good practice to add $themeData = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
184
        // $this->container->logger->debug("config: ".print_r($config, true));
0 ignored issues
show
Unused Code Comprehensibility introduced by
65% 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...
185
186
        // Generate data for grid
187
        $item = [
188
            'url' => "#",
189
            'image' => "/images/grid-item.png",
190
            'name' => "Item"
191
        ];
192
        $items = array();
193
        $max = (int)$args['param'];
194
        $this->container->logger->debug("param: ".$max);
195
196 View Code Duplication
        for($i = 0; $i < $max; $i++) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
197
            $item['name'] = "Item $i";
198
            $items[] = $item;
199
        }
200
201
        $themeData['page'] = [
202
            'title' => "Grid Example",
203
            'items' => $items
204
            ];
205
206
        return $this->container->theme->render($response, $view, $themeData);
207
    }
208
209 View Code Duplication
    public function getFullpage($request, $response, $args)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
210
    {
211
        $view = 'fullpage.html';
212
213
        // Get erdiko config, this gets application.json and loads the theme specified
214
        $themeData['theme'] = \erdiko\theme\Config::get($this->container->get('settings')['theme']);
0 ignored issues
show
Coding Style Comprehensibility introduced by
$themeData was never initialized. Although not strictly required by PHP, it is generally a good practice to add $themeData = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
215
        $themeData['page'] = [
216
            'title' => "Fullpage Example",
217
            'description' => "This is the description of the page."
218
            ];
219
220
        return $this->container->theme->render($response, $view, $themeData);
221
    }
222
223 View Code Duplication
    public function getException($request, $response, $args)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
224
    {
225
        $view = 'page.html';
0 ignored issues
show
Unused Code introduced by
$view is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
226
227
        throw new \Exception("This is an exception");
228
229
        // Get erdiko config, this gets application.json and loads the theme specified
230
        $themeData['theme'] = \erdiko\theme\Config::get($this->container->get('settings')['theme']);
0 ignored issues
show
Unused Code introduced by
// Get erdiko config, th...('settings')['theme']); does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
231
        $themeData['page'] = [
232
            'title' => "Fullpage Example",
233
            'description' => "This is the description of the page."
234
            ];
235
236
        return $this->container->theme->render($response, $view, $themeData);
237
    }
238
}
239