Passed
Push — master ( e34aef...380f9e )
by Gabor
09:54
created

IndexAction::__construct()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 80
Code Lines 57

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 80
rs 8.8387
c 0
b 0
f 0
cc 1
eloc 57
nc 1
nop 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
/**
3
 * WebHemi.
4
 *
5
 * PHP version 7.1
6
 *
7
 * @copyright 2012 - 2017 Gixx-web (http://www.gixx-web.com)
8
 * @license   https://opensource.org/licenses/MIT The MIT License (MIT)
9
 *
10
 * @link      http://www.gixx-web.com
11
 */
12
declare(strict_types = 1);
13
14
namespace WebHemi\Middleware\Action\Website;
15
16
use WebHemi\Middleware\Action\AbstractMiddlewareAction;
17
18
/**
19
 * Class IndexAction.
20
 */
21
class IndexAction extends AbstractMiddlewareAction
22
{
23
    /** @var array */
24
    protected $database = [];
25
26
    /**
27
     * IndexAction constructor.
28
     */
29
    public function __construct()
30
    {
31
        $this->database = [
32
            [
33
                'title'       => 'How to start a perfect day',
34
                'summary'     => 'Good to know...',
35
                'category'    => ['useful' => 'Useful infos'],
36
                'tags'        => ['php' => 'PHP', 'coding' => 'Coding'],
37
                'illustration'=> '/data/upload/filesystem/images/Nature.jpg',
38
                'path'        => 'posts/view/a_perfect_day.html',
39
                'publishedAt' => time(),
40
                'location'    => 'München',
41
                'author'      => [
42
                    'name'   => 'Amadeus',
43
                    'username'=> 'a.madeus',
44
                    'avatar' => '/data/upload/avatars/a.madeus.png',
45
                    'mood'   => ['feels cozy', 'hugging'],
46
                ],
47
                'contentLead' => 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod 
48
                                       tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At 
49
                                       vero eos et accusam et justo duo dolores et ea rebum.'
50
            ],
51
            [
52
                'title'       => 'Just an idea',
53
                'summary'     => null,
54
                'category'    => ['posts' => 'Posts'],
55
                'tags'        => ['php' => 'PHP', 'coding' => 'Coding'],
56
                'illustration'=> null,
57
                'path'        => 'notepad/just_an_idea.html',
58
                'publishedAt' => time(),
59
                'location'    => null,
60
                'author'      => [
61
                    'name'   => 'Gabor',
62
                    'username'=> 'gabor',
63
                    'avatar' => '/data/upload/avatars/gabor.png',
64
                    'mood'   => null,
65
                ],
66
                'contentLead' => 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod
67
                                       tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At
68
                                       vero eos et accusam et justo duo dolores et ea rebum.'
69
            ],
70
            [
71
                'title'       => 'An Owl',
72
                'category'    => ['events' => 'Events'],
73
                'tags'        => ['munich' => 'Munich'],
74
                'illustration'=> '/data/upload/filesystem/images/Owl.jpg',
75
                'path'        => 'nature/birds/notes/an_owl.html',
76
                'publishedAt' => time(),
77
                'location'    => 'München',
78
                'author'      => [
79
                    'name'   => 'Amadeus',
80
                    'username'=> 'a.madeus',
81
                    'avatar' => '/data/upload/avatars/a.madeus.png',
82
                    'mood'   => ['feels cozy', 'hugging'],
83
                ],
84
                'contentLead' => 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod 
85
                                       tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At 
86
                                       vero eos et accusam et justo duo dolores et ea rebum.'
87
            ],
88
            [
89
                'title'       => 'The new Spiderman movie',
90
                'summary'     => 'I didn\'t see it yet',
91
                'category'    => ['something' => 'Something'],
92
                'tags'        => ['munich' => 'Munich'],
93
                'illustration'=> '/data/upload/filesystem/images/Spider.jpg',
94
                'path'        => 'nature/arthropods/spidey.html',
95
                'publishedAt' => time(),
96
                'location'    => 'München',
97
                'author'      => [
98
                    'name'   => 'Amadeus',
99
                    'username'=> 'a.madeus',
100
                    'avatar' => '/data/upload/avatars/a.madeus.png',
101
                    'mood'   => ['feels cozy', 'hugging'],
102
                ],
103
                'contentLead' => 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod
104
                                       tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At
105
                                       vero eos et accusam et justo duo dolores et ea rebum.'
106
            ]
107
        ];
108
    }
109
110
    /**
111
     * Gets template map name or template file path.
112
     *
113
     * @return string
114
     */
115
    public function getTemplateName() : string
116
    {
117
        return 'website-index';
118
    }
119
120
    /**
121
     * Gets template data.
122
     *
123
     * @return array
124
     */
125
    public function getTemplateData() : array
126
    {
127
        return [
128
            'activeMenu' => '',
129
            'categories' => [
130
                ['url' => 'posts',      'title' => 'Posts',        'icon' => 'chrome_reader_mode',      'new' => 1],
131
                ['url' => 'useful',     'title' => 'Useful infos', 'icon' => 'perm_device_information', 'new' => 0],
132
                ['url' => 'events',     'title' => 'Events',       'icon' => 'event_note',              'new' => 0],
133
                ['url' => 'something',  'title' => 'Something',    'icon' => null,                      'new' => 8],
134
            ],
135
            'tags' => [
136
                ['url' => 'php',    'title' => 'PHP',    'total' => 132, 'new' =>  1],
137
                ['url' => 'coding', 'title' => 'Coding', 'total' => 132, 'new' =>  0],
138
                ['url' => 'munich', 'title' => 'Munich', 'total' => 132, 'new' => 85]
139
            ],
140
            'blogPosts' => $this->database,
141
            'fixPost' => [
142
                'title'       => 'Welcome to my blog!',
143
                'summary'     => null,
144
                'category'    => null,
145
                'tags'        => null,
146
                'illustration'=> null,
147
                'path'        => 'welcome.html',
148
                'publishedAt' => time(),
149
                'location'    => null,
150
                'author'      => [
151
                    'name'   => 'Gabor',
152
                    'username'=> 'gabor',
153
                    'avatar' => '/data/upload/avatars/gabor.png',
154
                    'mood'   => null,
155
                ],
156
                'contentLead' => 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod 
157
                                       tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At 
158
                                       vero eos et accusam et justo duo dolores et ea rebum.'
159
            ],
160
        ];
161
    }
162
}
163