Menu   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 19
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A renderItem() 0 13 2
1
<?php
2
3
4
namespace carono\exchange1c\widgets;
5
6
7
use yii\helpers\ArrayHelper;
8
use yii\helpers\Html;
9
use yii\helpers\Url;
10
11
class Menu extends \yii\widgets\Menu
12
{
13
    /**
14
     * @param array $item
15
     * @return string
16
     */
17
    protected function renderItem($item)
18
    {
19
        if (isset($item['url'])) {
20
            $template = ArrayHelper::getValue($item, 'template', $this->linkTemplate);
21
            return strtr($template, [
22
                '{url}' => Html::encode(Url::to($item['url'])),
23
                '{label}' => $item['label'],
24
                '{options}' => trim(Html::renderTagAttributes(ArrayHelper::getValue($item, 'linkOptions', [])))
25
            ]);
26
        }
27
        $template = ArrayHelper::getValue($item, 'template', $this->labelTemplate);
28
        return strtr($template, [
29
            '{label}' => $item['label'],
30
        ]);
31
    }
32
}