IpTag::init()   B
last analyzed

Complexity

Conditions 6
Paths 6

Size

Total Lines 22

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 42

Importance

Changes 0
Metric Value
dl 0
loc 22
ccs 0
cts 20
cp 0
rs 8.9457
c 0
b 0
f 0
cc 6
nc 6
nop 0
crap 42
1
<?php
2
/**
3
 * Hosting Plugin for HiPanel
4
 *
5
 * @link      https://github.com/hiqdev/hipanel-module-hosting
6
 * @package   hipanel-module-hosting
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2015-2019, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hipanel\modules\hosting\widgets\ip;
12
13
use hipanel\widgets\Label;
14
use Yii;
15
16
class IpTag extends Label
17
{
18
    public $tag = '';
19
20
    public function init()
21
    {
22
        $tag = $this->tag;
23
24
        if ($tag === 'static') {
25
            $class = 'success';
26
        } elseif ($tag === 'aux') {
27
            $class = 'default';
28
        } elseif ($tag === 'gateway') {
29
            $class = 'primary';
30
        } elseif ($tag === 'movement') {
31
            $class = 'danger';
32
        } elseif ($tag === 'anycast') {
33
            $class = 'info';
34
        } else {
35
            $class = 'default';
36
        }
37
38
        $this->color = $class;
0 ignored issues
show
Bug introduced by
The property color does not seem to exist. Did you mean _color?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
39
        $this->label = Yii::t('hipanel:hosting', $tag);
0 ignored issues
show
Bug introduced by
The property label does not seem to exist. Did you mean _label?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
40
        parent::init();
41
    }
42
}
43