Completed
Push — erdiko2 ( f39f1b...fec6a2 )
by John
02:29
created

Examples::getTwocolumn()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 6

Duplication

Lines 11
Ratio 100 %

Importance

Changes 0
Metric Value
dl 11
loc 11
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 3
1
<?php
2
namespace app\controllers;
3
4
class Examples extends \erdiko\controllers\Web
5
{
6
    use \erdiko\theme\traits\Controller;
7
8 View Code Duplication
    public function get($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...
9
    {
10
        $this->container->logger->debug("examples");
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();
15
        // $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...
16
        $themeData['page'] = [
17
            'title' => "Erdiko Web Example",
18
            'hello' => "world"
19
            ];
20
21
        return $this->container->theme->render($response, $view, $themeData);
22
    }
23
24
25 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...
26
    {
27
        $this->container->logger->debug("route: /config");
28
        $view = 'layouts/1column.html';
29
30
        // Get erdiko config, this gets application.json and loads the theme specified
31
        $config = \erdiko\theme\Config::get();
32
        $config['page']['title'] = "1 Column Layout";
33
34
        return $this->container->theme->render($response, $view, $config);
35
    }
36
37 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...
38
    {
39
        $this->container->logger->debug("route: /config");
40
        $view = 'layouts/2column.html';
41
42
        // Get erdiko config, this gets application.json and loads the theme specified
43
        $config = \erdiko\theme\Config::get();
44
        $config['page']['title'] = "2 Column Layout";
45
46
        return $this->container->theme->render($response, $view, $config);
47
    }
48
49 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...
50
    {
51
        $this->container->logger->debug("route: /config");
52
        $view = 'layouts/3column.html';
53
54
        // Get erdiko config, this gets application.json and loads the theme specified
55
        $config = \erdiko\theme\Config::get();
56
        $config['page']['title'] = "3 Column Layout";
57
58
        return $this->container->theme->render($response, $view, $config);
59
    }
60
61 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...
62
    {
63
        $view = 'pages/example.html';
64
65
        // Get erdiko config, this gets application.json and loads the theme specified
66
        $themeData = \erdiko\theme\Config::get();
67
        $themeData['args'] = $args; // optional
68
        $themeData['page'] = [
69
            'title' => "Erdiko Web Example"
70
            ];
71
72
        return $this->container->theme->render($response, $view, $themeData);
73
    }
74
75 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...
76
    {
77
        $view = 'examples/markup.html';
78
79
        // Get erdiko config, this gets application.json and loads the theme specified
80
        $themeData = \erdiko\theme\Config::get();
81
        $themeData['args'] = $args; // optional
82
        $themeData['page'] = [
83
            'title' => "Markup Example"
84
            ];
85
86
        return $this->container->theme->render($response, $view, $themeData);
87
    }
88
89 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...
90
    {
91
        $view = 'examples/carousel.html';
92
93
        // Get erdiko config, this gets application.json and loads the theme specified
94
        $themeData = \erdiko\theme\Config::get();
95
        $themeData['page'] = [
96
            'title' => "Fullpage Example",
97
            'description' => "This is the description of the page."
98
            ];
99
100
        return $this->container->theme->render($response, $view, $themeData);
101
    }
102
103
    public function getTheme($request, $response, $args)
104
    {
105
        // $view = 'examples/theme.html';
0 ignored issues
show
Unused Code Comprehensibility introduced by
43% 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...
106
        $theme = new \erdiko\theme\Engine;
107
        $theme->title = "Theme Engine Example";
108
        $theme->description = "This page is rendered using the theme engine.  
109
            \\erdiko\\theme\\Engine";
110
111
        return $this->render($response, null, $theme);
112
    }
113
114
    public function getFlash($request, $response, $args)
115
    {
116
        $view = 'page.html';
117
118
        // Add some flash messages
119
        $this->container->flash->addMessage('success', 'This is a success message');
120
        $this->container->flash->addMessage('info', 'This is an info message');
121
        $this->container->flash->addMessage('warning', 'This is a warning message');
122
        $this->container->flash->addMessage('danger', 'This is a danger (error) message'); 
123
124
        // Get erdiko config, this gets application.json and loads the theme specified
125
        $themeData = \erdiko\theme\Config::get();
126
        $themeData['args'] = $args;
127
        $themeData['page'] = [
128
            'title' => "Flash Message Example"
129
            ];
130
131
        return $this->container->theme->render($response, $view, $themeData);
132
    }
133
134
    public function getGrid($request, $response, $args)
135
    {
136
        $this->container->logger->debug("/controller");
137
        $view = 'examples/grid.html';
138
139
        // Get erdiko config, this gets application.json and loads the theme specified
140
        $themeData = \erdiko\theme\Config::get();
141
        // $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...
142
143
        // Generate data for grid
144
        $item = [
145
            'url' => "#",
146
            'image' => "/images/grid-item.png",
147
            'name' => "Item"
148
        ];
149
        $items = array();
150
        $max = (int)$args['param'];
151
        $this->container->logger->debug("param: ".$max);
152
153 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...
154
            $item['name'] = "Item $i";
155
            $items[] = $item;
156
        }
157
158
        $themeData['page'] = [
159
            'title' => "Grid Example",
160
            'items' => $items
161
            ];
162
    
163
        return $this->container->theme->render($response, $view, $themeData);
164
    }
165
166 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...
167
    {
168
        $view = 'fullpage.html';
169
170
        // Get erdiko config, this gets application.json and loads the theme specified
171
        $themeData = \erdiko\theme\Config::get();
172
        $themeData['page'] = [
173
            'title' => "Fullpage Example",
174
            'description' => "This is the description of the page."
175
            ];
176
177
        return $this->container->theme->render($response, $view, $themeData);
178
    }
179
180
    public function getException($request, $response, $args)
181
    {
182
        $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...
183
184
        throw new \Exception("This is an exception");
185
186
        // Get erdiko config, this gets application.json and loads the theme specified
187
        $themeData = \erdiko\theme\Config::get();
0 ignored issues
show
Unused Code introduced by
// Get erdiko config, th...ko\theme\Config::get(); 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...
188
        $themeData['page'] = [
189
            'title' => "Fullpage Example",
190
            'description' => "This is the description of the page."
191
            ];
192
193
        return $this->container->theme->render($response, $view, $themeData);
194
    }
195
}