Completed
Push — master ( ed8952...fe4715 )
by Vladimir
02:26
created

PulseColumnStatusValue   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 85
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getValue() 0 9 2
A updateValue() 0 17 3
1
<?php
2
3
namespace allejo\DaPulse\Objects;
4
5
/**
6
 * Class PulseColumnColorValue
7
 *
8
 * @package allejo\DaPulse\Objects
9
 */
10
class PulseColumnStatusValue extends PulseColumnValue
11
{
12
    /**
13
     * The index of the orange status
14
     */
15
    const Orange = 0;
0 ignored issues
show
Coding Style introduced by
This class constant is not uppercase (expected ORANGE).
Loading history...
16
17
    /**
18
     * The index of the light green status
19
     */
20
    const L_Green = 1;
0 ignored issues
show
Coding Style introduced by
This class constant is not uppercase (expected L_GREEN).
Loading history...
21
22
    /**
23
     * The index of the red status
24
     */
25
    const Red = 2;
0 ignored issues
show
Coding Style introduced by
This class constant is not uppercase (expected RED).
Loading history...
26
27
    /**
28
     * The index of the blue status
29
     */
30
    const Blue = 3;
0 ignored issues
show
Coding Style introduced by
This class constant is not uppercase (expected BLUE).
Loading history...
31
32
    /**
33
     * The index of the purple status
34
     */
35
    const Purple = 4;
0 ignored issues
show
Coding Style introduced by
This class constant is not uppercase (expected PURPLE).
Loading history...
36
37
    /**
38
     * The index of the grey status
39
     */
40
    const Grey = 5;
0 ignored issues
show
Coding Style introduced by
This class constant is not uppercase (expected GREY).
Loading history...
41
42
    /**
43
     * The index of the green status
44
     */
45
    const Green = 6;
0 ignored issues
show
Coding Style introduced by
This class constant is not uppercase (expected GREEN).
Loading history...
46
47
    /**
48
     * The index of the light blue status
49
     */
50
    const L_Blue = 7;
0 ignored issues
show
Coding Style introduced by
This class constant is not uppercase (expected L_BLUE).
Loading history...
51
52
    /**
53
     * The index of the gold status
54
     */
55
    const Gold = 8;
0 ignored issues
show
Coding Style introduced by
This class constant is not uppercase (expected GOLD).
Loading history...
56
57
    /**
58
     * The index of the yellow status
59
     */
60
    const Yellow = 9;
0 ignored issues
show
Coding Style introduced by
This class constant is not uppercase (expected YELLOW).
Loading history...
61
62
    /**
63
     * The index of the black status
64
     */
65
    const Black = 10;
0 ignored issues
show
Coding Style introduced by
This class constant is not uppercase (expected BLACK).
Loading history...
66
67
    public function getValue ()
68
    {
69
        if (!isset($this->column_value))
70
        {
71
            $this->column_value = $this->jsonResponse["value"]["index"];
72
        }
73
74
        return $this->column_value;
75
    }
76
77
    public function updateValue ($color)
78
    {
79
        if ($color < 0 && $color > 10)
80
        {
81
            throw new \InvalidArgumentException("DaPulse only has color indexes from 0-10");
82
        }
83
84
        $url        = sprintf("%s/%d/columns/%s/status.json", parent::apiEndpoint(), $this->board_id, $this->column_id);
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (apiEndpoint() instead of updateValue()). Are you sure this is correct? If so, you might want to change this to $this->apiEndpoint().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
85
        $postParams = array(
86
            "pulse_id"    => $this->pulse_id,
87
            "color_index" => $color
88
        );
89
90
        self::sendPut($url, $postParams);
91
92
        $this->column_value = $color;
93
    }
94
}