Completed
Push — master ( 337a7a...4b54e5 )
by Klochok
03:51
created

DbDetailMenu::items()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 54
Code Lines 35

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 54
ccs 0
cts 54
cp 0
rs 9.6716
cc 1
eloc 35
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
namespace hipanel\modules\hosting\menus;
4
5
use hipanel\widgets\ModalButton;
6
use hiqdev\menumanager\Menu;
7
use Yii;
8
use yii\helpers\Html;
9
10
class DbDetailMenu extends Menu
11
{
12
    public $model;
13
14
    public function items()
15
    {
16
        return [
17
            [
18
                'label' => $this->renderView('_change-password', ['model' => $this->model]),
19
                'encode' => false,
20
            ],
21
            [
22
                'label' => ModalButton::widget([
23
                    'model' => $this->model,
24
                    'scenario' => 'truncate',
25
                    'button' => [
26
                        'label' => '<i class="fa fa-fw fa-file-o"></i>' . Yii::t('hipanel:hosting', 'Truncate'),
27
                    ],
28
                    'modal' => [
29
                        'header' => Html::tag('h4', Yii::t('hipanel:hosting', 'Confirm database truncating')),
30
                        'headerOptions' => ['class' => 'label-danger'],
31
                        'footer' => [
32
                            'label' => Yii::t('hipanel:hosting', 'Truncate database'),
33
                            'data-loading-text' => Yii::t('hipanel', 'Performing...'),
34
                            'class' => 'btn btn-danger',
35
                        ]
36
                    ],
37
                    'body' => Yii::t('hipanel:hosting',
38
                        'Are you sure that to truncate database {name}? All tables will be dropped, all data will be lost!',
39
                        ['name' => Html::tag('b', $this->model->name)]
40
                    )
41
                ]),
42
                'encode' => false,
43
            ],
44
            [
45
                'label' => ModalButton::widget([
46
                    'model' => $this->model,
47
                    'scenario' => 'delete',
48
                    'button' => [
49
                        'label' => '<i class="fa fa-fw fa-trash-o"></i>' . Yii::t('hipanel', 'Delete'),
50
                    ],
51
                    'modal' => [
52
                        'header' => Html::tag('h4', Yii::t('hipanel:hosting', 'Confirm database deleting')),
53
                        'headerOptions' => ['class' => 'label-danger'],
54
                        'footer' => [
55
                            'label' => Yii::t('hipanel:hosting', 'Delete database'),
56
                            'data-loading-text' => Yii::t('hipanel', 'Deleting...'),
57
                            'class' => 'btn btn-danger',
58
                        ]
59
                    ],
60
                    'body' => Yii::t('hipanel:hosting', 'Are you sure to delete database {name}? All tables will be dropped, all data will be lost!',
61
                        ['name' => Html::tag('b', $this->model->name)]
62
                    )
63
                ]),
64
                'encode' => false,
65
            ],
66
        ];
67
    }
68
69
    public function getViewPath()
70
    {
71
        return '@vendor/hiqdev/hipanel-module-hosting/src/views/db';
72
    }
73
}
74