Completed
Push — master ( 594a1c...ddb6e9 )
by Klochok
13:13
created

RequestGridLegend::items()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 37
Code Lines 20

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 37
rs 8.8571
cc 1
eloc 20
nc 1
nop 0
1
<?php
2
3
namespace hipanel\modules\hosting\grid;
4
5
use hipanel\widgets\gridLegend\BaseGridLegend;
6
use hipanel\widgets\gridLegend\GridLegendInterface;
7
use Yii;
8
9
class RequestGridLegend extends BaseGridLegend implements GridLegendInterface
10
{
11
    public function items()
12
    {
13
        return [
14
            [
15
                'label' => Yii::t('hipanel:hosting', 'Already'),
16
                'color' => '#E0E0E0',
17
            ],
18
            [
19
                'label' => Yii::t('hipanel:hosting', 'Deferred'),
20
                'color' => '#AAAAFF',
21
                'rule' => $this->model->type === 'free',
0 ignored issues
show
Bug introduced by
Accessing type on the interface yii\db\ActiveRecordInterface suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
22
            ],
23
            [
24
                'label' => Yii::t('hipanel:hosting', 'New'),
25
                'color' => '#FFFF99',
26
                'rule' => $this->model->state === 'new',
0 ignored issues
show
Bug introduced by
Accessing state on the interface yii\db\ActiveRecordInterface suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
27
            ],
28
            [
29
                'label' => Yii::t('hipanel:hosting', 'In progress'),
30
                'color' => '#AAFFAA',
31
                'rule' => $this->model->state === 'progress',
0 ignored issues
show
Bug introduced by
Accessing state on the interface yii\db\ActiveRecordInterface suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
32
            ],
33
            [
34
                'label' => Yii::t('hipanel:hosting', 'Done'),
35
            ],
36
            [
37
                'label' => Yii::t('hipanel:hosting', 'Error'),
38
                'color' => '#FFCCCC',
39
                'rule' => $this->model->state === 'error',
0 ignored issues
show
Bug introduced by
Accessing state on the interface yii\db\ActiveRecordInterface suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
40
            ],
41
            [
42
                'label' => Yii::t('hipanel:hosting', 'Buzzed'),
43
                'color' => '#FFCCCC',
44
                'rule' => $this->model->state === 'buzzed',
0 ignored issues
show
Bug introduced by
Accessing state on the interface yii\db\ActiveRecordInterface suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
45
            ],
46
        ];
47
    }
48
}