State::init()   A
last analyzed

Complexity

Conditions 4
Paths 3

Size

Total Lines 15

Duplication

Lines 15
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 20

Importance

Changes 0
Metric Value
dl 15
loc 15
ccs 0
cts 14
cp 0
rs 9.7666
c 0
b 0
f 0
cc 4
nc 3
nop 0
crap 20
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\account;
12
13
use hipanel\widgets\Label;
14
use Yii;
15
16 View Code Duplication
class State extends Label
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
17
{
18
    public $model = [];
19
20
    public function init()
21
    {
22
        $state = $this->model->state;
23
        if ($state === 'ok' || $state === 'active') {
24
            $class = 'info';
25
        } elseif ($state === 'blocked') {
26
            $class = 'danger';
27
        } else {
28
            $class = 'warning';
29
        }
30
31
        $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...
32
        $this->label = Yii::t('hipanel:hosting', $this->model->state_label);
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...
33
        parent::init();
34
    }
35
}
36