TariffActionsMenu   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 1
lcom 1
cbo 4
dl 0
loc 35
ccs 0
cts 30
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A items() 0 30 1
1
<?php
2
/**
3
 * Finance module for HiPanel
4
 *
5
 * @link      https://github.com/hiqdev/hipanel-module-finance
6
 * @package   hipanel-module-finance
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2015-2019, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hipanel\modules\finance\menus;
12
13
use hipanel\widgets\ModalButton;
14
use Yii;
15
use yii\helpers\Html;
16
17
class TariffActionsMenu extends \hiqdev\yii2\menus\Menu
18
{
19
    public $model;
20
21
    public function items()
22
    {
23
        return [
24
            [
25
                'label' => Yii::t('hipanel', 'Update'),
26
                'icon' => 'fa-pencil',
27
                'url' => ['@tariff/update', 'id' => $this->model->id],
28
                'visible' => Yii::$app->user->can('plan.update'),
29
            ],
30
            [
31
                'label' => ModalButton::widget([
32
                    'model' => $this->model->getTariff(),
33
                    'scenario' => 'delete',
34
                    'button' => ['label' => '<i class="fa fa-fw fa-trash-o"></i>' . Yii::t('hipanel', 'Delete')],
35
                    'body' => Yii::t('hipanel:finance:tariff', 'Tariff must be unlinked form all objects before. Are you sure you want to delete tariff {name}?', ['name' => $model->name]),
0 ignored issues
show
Bug introduced by
The variable $model does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
36
                    'modal' => [
37
                        'header' => Html::tag('h4', Yii::t('hipanel:finance:tariff', 'Confirm tariff deleting')),
38
                        'headerOptions' => ['class' => 'label-danger'],
39
                        'footer' => [
40
                            'label' => Yii::t('hipanel:finance:tariff', 'Delete tariff'),
41
                            'data-loading-text' => Yii::t('hipanel:finance:tariff', 'Deleting tariff...'),
42
                            'class' => 'btn btn-danger',
43
                        ],
44
                    ],
45
                ]),
46
                'visible' => Yii::$app->user->can('plan.delete'),
47
                'encode' => false,
48
            ],
49
        ];
50
    }
51
}
52