Completed
Push — master ( 669d4a...cba942 )
by Andrii
05:17 queued 03:45
created

BackupingDetailMenu::items()   B

Complexity

Conditions 2
Paths 2

Size

Total Lines 74

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 74
ccs 0
cts 73
cp 0
rs 8.5672
c 0
b 0
f 0
cc 2
nc 2
nop 0
crap 6

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
 * Hosting Plugin for HiPanel
4
 *
5
 * @link      https://github.com/hiqdev/hipanel-module-hosting
6
 * @package   hipanel-module-hosting
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2015-2019, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hipanel\modules\hosting\menus;
12
13
use Yii;
14
15
class BackupingDetailMenu extends \hipanel\menus\AbstractDetailMenu
16
{
17
    public $model;
18
19
    public function items()
20
    {
21
        return [
22
            [
23
                'label' => Yii::t('hipanel:hosting', 'Update settings'),
24
                'icon' => 'fa-pencil',
25
                'url' => ['@backuping/update', 'id' => $this->model->id],
26
                'encode' => false,
27
                'visible' => Yii::$app->user->can('support') && !$this->model->isDeleted(),
28
            ],[
29
                'label' => Yii::t('hipanel', 'Enable'),
30
                'icon' => 'fa-activate',
31
                'url' => ['@backuping/enable', 'id' => $this->model->id],
32
                'encode' => false,
33
                'visible' => $this->model->canBeEnabled(),
34
                'linkOptions' => [
35
                    'data' => [
36
                        'method' => 'post',
37
                        'pjax' => '0',
38
                        'params' => [
39
                            'Backuping[id]' => $this->model->id,
40
                        ],
41
                    ],
42
                ],
43
            ], [
44
                'label' => Yii::t('hipanel', 'Restore'),
45
                'icon' => 'fa-archive',
46
                'url' => ['@backuping/undelete', 'id' => $this->model->id],
47
                'encode' => false,
48
                'visible' => $this->model->canBeRestored(),
49
                'linkOptions' => [
50
                    'data' => [
51
                        'method' => 'post',
52
                        'pjax' => '0',
53
                        'params' => [
54
                            'Backuping[id]' => $this->model->id,
55
                        ],
56
                    ],
57
                ],
58
            ], [
59
                'label' => Yii::t('hipanel', 'Disable'),
60
                'icon' => 'fa-ban',
61
                'url' => ['@backuping/disable', 'id' => $this->model->id],
62
                'encode' => false,
63
                'visible' => $this->model->canBeDisabled(),
64
                'linkOptions' => [
65
                    'data' => [
66
                        'method' => 'post',
67
                        'pjax' => '0',
68
                        'params' => [
69
                            'Backuping[id]' => $this->model->id,
70
                        ],
71
                    ],
72
                ],
73
            ], [
74
                'label' => Yii::t('hipanel', 'Delete'),
75
                'icon' => 'fa-trash',
76
                'url' => ['@backuping/delete', 'id' => $this->model->id],
77
                'encode' => false,
78
                'visible' => $this->model->canBeDeleted(),
79
                'linkOptions' => [
80
                    'data' => [
81
                        'confirm' => Yii::t('hipanel:hosting', 'Are you sure you want to delete backuping?'),
82
                        'method' => 'post',
83
                        'pjax' => '0',
84
                        'params' => [
85
                            'Backuping[id]' => $this->model->id,
86
                        ],
87
                    ],
88
                ],
89
90
            ],
91
        ];
92
    }
93
}
94