Topic::run()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
dl 0
loc 12
ccs 0
cts 12
cp 0
rs 9.8666
c 0
b 0
f 0
cc 3
nc 3
nop 0
crap 12
1
<?php
2
/**
3
 * HiPanel tickets module
4
 *
5
 * @link      https://github.com/hiqdev/hipanel-module-ticket
6
 * @package   hipanel-module-ticket
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2015-2017, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hipanel\modules\ticket\widgets;
12
13
use Yii;
14
use yii\helpers\Html;
15
use yii\jui\Widget;
16
17
class Topic extends Widget
18
{
19
    public $topics;
20
21
    private function _getColor($item)
22
    {
23
        $colors = [
24
           'general'   => 'label-default',
25
           'technical' => 'label-primary',
26
           'vds'       => 'label-info',
27
           'domain'    => 'label-success',
28
           'financial' => 'label-warning',
29
        ];
30
31
        return $colors[$item] ?: reset($colors);
32
    }
33
34
    public function run()
35
    {
36
        if ($this->topics) {
37
            $html = '<ul class="list-inline">';
38
            foreach ($this->topics as $item => $label) {
39
                $label = Yii::t('hipanel:ticket', Html::encode($label));
40
                $html .= Html::tag('li', Html::tag('span', $label, ['class' => 'label ' . $this->_getColor($item)]));
41
            }
42
            $html .= '</ul>';
43
            echo $html;
44
        }
45
    }
46
}
47