Completed
Push — master ( ce194a...ac6b1c )
by Klochok
13:10
created

ServerActionsMenu::items()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 80
Code Lines 55

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 80
ccs 0
cts 2
cp 0
rs 8.8387
cc 1
eloc 55
nc 1
nop 0
crap 2

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
 * Server module for HiPanel.
4
 *
5
 * @link      https://github.com/hiqdev/hipanel-module-server
6
 * @package   hipanel-module-server
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2015-2017, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hipanel\modules\server\menus;
12
13
use Yii;
14
15
class ServerActionsMenu extends \hiqdev\yii2\menus\Menu
16
{
17
    public $model;
18
19
    public function items()
20
    {
21
        return [
22
            'view' => [
23
                'label' => Yii::t('hipanel', 'View'),
24
                'icon' => 'fa-info',
25
                'url' => ['@server/view', 'id' => $this->model->id],
26
                'linkOptions' => [
27
                    'data-pjax' => 0,
28
                ],
29
            ],
30
            'update' => [
31
                'label' => Yii::t('hipanel', 'Update'),
32
                'icon' => 'fa-pencil',
33
                'url' => ['@server/update', 'id' => $this->model->id],
34
                'visible' => false,
35
                'linkOptions' => [
36
                    'data-pjax' => 0,
37
                ],
38
            ],
39
            [
40
                'label' => Yii::t('hipanel:server', 'Performance graphs'),
41
                'icon' => 'fa-signal',
42
                'url' => ['@rrd/view', 'id' => $this->model->id],
43
                'linkOptions' => [
44
                    'data-pjax' => 0,
45
                ],
46
            ],
47
            [
48
                'label' => Yii::t('hipanel:server', 'Switch graphs'),
49
                'icon' => 'fa-area-chart',
50
                'url' => ['@switch-graph/view', 'id' => $this->model->id],
51
                'linkOptions' => [
52
                    'data-pjax' => 0,
53
                ],
54
            ],
55
            'hw' => [
56
                'label' => Yii::t('hipanel:server', 'Hardware properties'),
57
                'icon' => 'fa-cogs',
58
                'url' => ['@server/hw', 'id' => $this->model->id],
59
                'linkOptions' => [
60
                    'data-pjax' => 0,
61
                ],
62
            ],
63
            'sw' => [
64
                'label' => Yii::t('hipanel:server', 'Software properties'),
65
                'icon' => 'fa-cogs',
66
                'url' => ['@server/sw', 'id' => $this->model->id],
67
                'linkOptions' => [
68
                    'data-pjax' => 0,
69
                ],
70
            ],
71
            'mon' => [
72
                'label' => Yii::t('hipanel:server', 'Monitoring properties'),
73
                'icon' => 'fa-cogs',
74
                'url' => ['@server/mon', 'id' => $this->model->id],
75
                'linkOptions' => [
76
                    'data-pjax' => 0,
77
                ],
78
            ],
79
            [
80
                'label' => Yii::t('hipanel:server', 'Server IPs'),
81
                'icon' => 'fa-user',
82
                'visible' => Yii::getAlias('@ip', false),
83
                'url' => ['@ip/index', 'IpSearch' => ['server_in' => $this->model->name]],
84
                'linkOptions' => [
85
                    'data-pjax' => 0,
86
                ],
87
            ],
88
            [
89
                'label' => Yii::t('hipanel:server', 'Server Accounts'),
90
                'icon' => 'fa-location-arrow',
91
                'visible' => Yii::getAlias('@account', false),
92
                'url' => ['@account/index', 'AccountSearch' => ['server' => $this->model->name]],
93
                'linkOptions' => [
94
                    'data-pjax' => 0,
95
                ],
96
            ],
97
        ];
98
    }
99
}
100