IpGridLegend::items()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 24

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 24
ccs 0
cts 24
cp 0
rs 9.536
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
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\grid;
12
13
use hipanel\widgets\gridLegend\BaseGridLegend;
14
use hipanel\widgets\gridLegend\GridLegendInterface;
15
use Yii;
16
17
class IpGridLegend extends BaseGridLegend implements GridLegendInterface
18
{
19
    public function items()
20
    {
21
        return [
22
            [
23
                'label' => Yii::t('hipanel:hosting', 'Shared'),
24
            ],
25
            [
26
                'label' => Yii::t('hipanel:hosting', 'Free'),
27
                'color' => '#AAFFAA',
28
                '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...
29
            ],
30
            [
31
                'label' => Yii::t('hipanel:hosting', 'Dedicated'),
32
                'color' => '#CCCCFF',
33
                '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...
34
            ],
35
            [
36
                'label' => Yii::t('hipanel:hosting', 'System'),
37
            ],
38
            [
39
                'label' => Yii::t('hipanel:hosting', 'Blocked'),
40
            ],
41
        ];
42
    }
43
}
44