Completed
Push — master ( 823023...c43f27 )
by Dmitry
06:01 queued 02:13
created

AbstractNameBadge   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 1
eloc 10
dl 0
loc 26
ccs 0
cts 1
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A run() 0 9 1
1
<?php
2
3
namespace hipanel\modules\server\widgets;
4
5
use hipanel\modules\server\forms\HubSellForm;
6
use hipanel\modules\server\models\Hub;
7
use hipanel\modules\server\models\Server;
8
use hipanel\widgets\gridLegend\GridLegend;
9
use yii\base\Widget;
10
11
abstract class AbstractNameBadge extends Widget
12
{
13
    /**
14
     * @var string
15
     */
16
    public $gridLegendClass;
17
18
    /**
19
     * @var string
20
     */
21
    public $nameAttribute = 'name';
22
23
    /**
24
     * @var Hub|Server|HubSellForm
25
     */
26
    public $model;
27
28
    public function run()
29
    {
30
        $color = GridLegend::create(new $this->gridLegendClass($this->model))->gridColumnOptions('actions');
31
        $colorString = implode(';', $color);
32
33
        $this->view->registerCss('.badge .item-badge-text { color: #bbbbbb; mix-blend-mode: difference; }');
34
35
        return <<<HTML
36
<span class="badge" style="$colorString"><span class="item-badge-text">{$this->model->{$this->nameAttribute}}</span></span>
37
HTML
38
            ;
39
    }
40
}
41
42