Entry::setValue()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
crap 1
1
<?php
2
3
namespace CarlosIO\Geckoboard\Data\PieChart;
4
5
/**
6
 * Class Entry.
7
 */
8
class Entry
9
{
10
    /**
11
     * @var string
12
     */
13
    protected $value;
14
15
    /**
16
     * @var string
17
     */
18
    protected $color = null;
19
20
    /**
21
     * @var string
22
     */
23
    protected $label;
24
25 1
    public function __construct()
26
    {
27 1
        $this->value = null;
28 1
        $this->label = null;
29 1
    }
30
31
    /**
32
     * @param $value
33
     *
34
     * @return $this
35
     */
36 1
    public function setValue($value)
37
    {
38 1
        $this->value = $value;
39
40 1
        return $this;
41
    }
42
43
    /**
44
     * @param  $label
45
     *
46
     * @return $this
47
     */
48 1
    public function setLabel($label)
49
    {
50 1
        $this->label = $label;
51
52 1
        return $this;
53
    }
54
55
    /**
56
     * @return string
57
     */
58 1
    public function getLabel()
59
    {
60 1
        return $this->label;
61
    }
62
63
    /**
64
     * @return string
65
     */
66 1
    public function getValue()
67
    {
68 1
        return $this->value;
69
    }
70
71
    /**
72
     * @return string
73
     */
74 1
    public function getColor()
75
    {
76 1
        return $this->color;
77
    }
78
79
    /**
80
     * @param string $color
81
     */
82 1
    public function setColor($color)
83
    {
84 1
        $this->color = $color;
85 1
    }
86
87
    /**
88
     * @return array
89
     */
90 1 View Code Duplication
    public function toArray()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
91
    {
92 1
        $result = array();
93
94 1
        $value = $this->getValue();
95 1
        if (null !== $value) {
96 1
            $result['value'] = (string) $value;
97 1
        }
98
99 1
        $label = $this->getLabel();
100 1
        if (null !== $label) {
101 1
            $result['label'] = $label;
102 1
        }
103
104 1
        $color = $this->getColor();
105 1
        if (null !== $color) {
106 1
            $result['color'] = $color;
107 1
        }
108
109 1
        return $result;
110
    }
111
}
112