Completed
Push — master ( 11841d...e0d7ad )
by Klochok
31:58 queued 17:00
created

IpGridLegend   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
lcom 1
cbo 2
dl 0
loc 27
rs 10
c 1
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B items() 0 24 1
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 IpGridLegend extends BaseGridLegend implements GridLegendInterface
10
{
11
    public function items()
12
    {
13
        return [
14
            [
15
                'label' => Yii::t('hipanel:hosting', 'Shared'),
16
            ],
17
            [
18
                'label' => Yii::t('hipanel:hosting', 'Free'),
19
                'color' => '#AAFFAA',
20
                '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...
21
            ],
22
            [
23
                'label' => Yii::t('hipanel:hosting', 'Dedicated'),
24
                'color' => '#CCCCFF',
25
                'rule' => $this->model->type === 'dedicated',
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...
26
            ],
27
            [
28
                'label' => Yii::t('hipanel:hosting', 'System'),
29
            ],
30
            [
31
                'label' => Yii::t('hipanel:hosting', 'Blocked'),
32
            ],
33
        ];
34
    }
35
}
36