Completed
Push — master ( 19a019...bc1809 )
by Klochok
11:54
created

DashboardItem   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 26
ccs 0
cts 20
cp 0
rs 10
c 0
b 0
f 0
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\helpers\Url;
14
use hipanel\modules\client\ClientWithCounters;
15
use hiqdev\yii2\menus\Menu;
16
use Yii;
17
18
class DashboardItem extends Menu
19
{
20
    protected ClientWithCounters $clientWithCounters;
0 ignored issues
show
Bug introduced by
This code did not parse for me. Apparently, there is an error somewhere around this line:

Syntax error, unexpected T_STRING, expecting T_FUNCTION or T_CONST
Loading history...
21
22
    public function __construct(ClientWithCounters $clientWithCounters, $config = [])
23
    {
24
        $this->clientWithCounters = $clientWithCounters;
25
        parent::__construct($config);
26
    }
27
28
    public function items()
29
    {
30
        $items = [];
31
        if (Yii::$app->user->can('bill.read')) {
32
            $items['bill'] = [
33
                'label' => $this->render('dashboardBillItem', $this->clientWithCounters->getWidgetData('bill')),
34
                'encode' => false,
35
            ];
36
        }
37
        if (Yii::$app->user->can('manage')) {
38
            $items['tariff'] = [
39
                'label' => $this->render('dashboardTariffItem', array_merge($this->clientWithCounters->getWidgetData('tariff'), [
40
                    'route' => Url::toRoute('@plan/index'),
41
                ])),
42
                'encode' => false,
43
            ];
44
        }
45
46
        return $items;
47
    }
48
}
49