DbDetailMenu::items()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 54

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

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