Completed
Push — erdiko2 ( 8a35d8...630309 )
by John
03:39
created

Examples::getFlash()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 19
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 19
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 11
nc 1
nop 3
1
<?php
2
namespace app\controllers;
3
4
class Examples extends \erdiko\controllers\Web
5
{
6 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...
7
    {
8
        $view = 'examples/list.html';
9
10
        // Get erdiko config, this gets application.json and loads the theme specified
11
        $themeData = \erdiko\theme\Config::get();
12
        $themeData['args'] = $args; // optional
13
        $themeData['page'] = [
14
            'title' => "Erdiko Web Example"
15
            ];
16
17
        return $this->container->theme->render($response, $view, $themeData);
18
    }
19
20 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...
21
    {
22
        $view = 'pages/example.html';
23
24
        // Get erdiko config, this gets application.json and loads the theme specified
25
        $themeData = \erdiko\theme\Config::get();
26
        $themeData['args'] = $args; // optional
27
        $themeData['page'] = [
28
            'title' => "Erdiko Web Example"
29
            ];
30
31
        return $this->container->theme->render($response, $view, $themeData);
32
    }
33
34 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...
35
    {
36
        $view = 'examples/markup.html';
37
38
        // Get erdiko config, this gets application.json and loads the theme specified
39
        $themeData = \erdiko\theme\Config::get();
40
        $themeData['args'] = $args; // optional
41
        $themeData['page'] = [
42
            'title' => "Markup Example"
43
            ];
44
45
        return $this->container->theme->render($response, $view, $themeData);
46
    }
47
48
    public function getFlash($request, $response, $args)
49
    {
50
        $view = 'bootstrap.html';
51
52
        // Add some flash messages
53
        $this->container->flash->addMessage('success', 'This is a success message');
54
        $this->container->flash->addMessage('info', 'This is an info message');
55
        $this->container->flash->addMessage('warning', 'This is a warning message');
56
        $this->container->flash->addMessage('danger', 'This is a danger (error) message'); 
57
58
        // Get erdiko config, this gets application.json and loads the theme specified
59
        $themeData = \erdiko\theme\Config::get();
60
        $themeData['args'] = $args;
61
        $themeData['page'] = [
62
            'title' => "Flash Message Example"
63
            ];
64
65
        return $this->container->theme->render($response, $view, $themeData);
66
    }
67
68
    public function getGrid($request, $response, $args)
69
    {
70
        $this->container->logger->debug("/controller");
71
        $view = 'examples/grid.html';
72
73
        // Get erdiko config, this gets application.json and loads the theme specified
74
        $themeData = \erdiko\theme\Config::get();
75
        // $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...
76
77
        $item = [
78
            'url' => "#",
79
            'image' => "/images/grid-item.png",
80
            'name' => "Item"
81
        ];
82
        $items = array();
83
        $max = (int)$args['param'];
84
        $this->container->logger->debug("param: ".$max);
85
86 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...
87
            $item['name'] = "Item $i";
88
            $items[] = $item;
89
        }
90
91
        $themeData['args'] = $args;
92
        $themeData['page'] = [
93
            'title' => "Grid Example",
94
            'items' => $items
95
            ];
96
    
97
        return $this->container->theme->render($response, $view, $themeData);
98
    }
99
}