Passed
Push — master ( 0ed0e7...6e487e )
by Aleksandr
01:28
created

Menu::renderItem()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 9
nc 2
nop 1
dl 0
loc 13
rs 9.4285
c 0
b 0
f 0
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
}