RequestGridLegend   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 1
c 0
b 0
f 0
lcom 1
cbo 1
dl 0
loc 56
ccs 0
cts 53
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A items() 0 53 1
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 DateTime;
14
use hipanel\widgets\gridLegend\BaseGridLegend;
15
use hipanel\widgets\gridLegend\GridLegendInterface;
16
17
class RequestGridLegend extends BaseGridLegend implements GridLegendInterface
18
{
19
    public function items()
20
    {
21
        return [
22
            [
23
                'label' => ['hipanel:hosting', 'Scheduled time:'],
24
                'tag' => 'h4',
25
            ],
26
            [
27
                'label' => ['hipanel:hosting', 'Already'],
28
                'color' => '#E0E0E0',
29
                'rule' => ((new DateTime($this->model->time)) < (new DateTime())),
0 ignored issues
show
Bug introduced by
Accessing time 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...
30
                'columns' => ['time'],
31
            ],
32
            [
33
                'label' => ['hipanel:hosting', 'Deferred'],
34
                'color' => '#AAAAFF',
35
                'rule' => ((new DateTime($this->model->time)) > (new DateTime())),
0 ignored issues
show
Bug introduced by
Accessing time 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...
36
                'columns' => ['time'],
37
            ],
38
            [
39
                'label' => ['hipanel:hosting', 'State:'],
40
                'tag' => 'h4',
41
            ],
42
            [
43
                'label' => ['hipanel:hosting', 'New'],
44
                'color' => '#FFFF99',
45
                '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...
46
                'columns' => ['state'],
47
            ],
48
            [
49
                'label' => ['hipanel:hosting', 'In progress'],
50
                'color' => '#AAFFAA',
51
                '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...
52
                'columns' => ['state'],
53
            ],
54
            [
55
                'label' => ['hipanel:hosting', 'Done'],
56
                'columns' => ['state'],
57
            ],
58
            [
59
                'label' => ['hipanel:hosting', 'Error'],
60
                'color' => '#FFCCCC',
61
                '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...
62
                'columns' => ['state'],
63
            ],
64
            [
65
                'label' => ['hipanel:hosting', 'Buzzed'],
66
                'color' => '#FFCCCC',
67
                '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...
68
                'columns' => ['state'],
69
            ],
70
        ];
71
    }
72
}
73