Item::toArray()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 20
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 15
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 20
ccs 15
cts 15
cp 1
rs 9.4285
cc 3
eloc 13
nc 4
nop 0
crap 3
1
<?php
2
3
namespace CarlosIO\Geckoboard\Data\Bullet;
4
5
/**
6
 * Class Item.
7
 */
8
class Item
9
{
10
    /**
11
     * @var string
12
     */
13
    protected $label;
14
15
    /**
16
     * @var string
17
     */
18
    protected $sublabel;
19
20
    /**
21
     * @var array
22
     */
23
    protected $axisPoint;
24
25
    /**
26
     * @var string
27
     */
28
    protected $range;
29
30
    /**
31
     * @var string
32
     */
33
    protected $measure;
34
35
    /**
36
     * @var string
37
     */
38
    protected $comparative;
39
40 1
    public function __construct()
41
    {
42 1
        $this->axisPoint = array();
43 1
        $this->label = null;
44 1
        $this->sublabel = null;
45 1
    }
46
47
    /**
48
     * @param $comparative
49
     *
50
     * @return $this
51
     */
52 1
    public function setComparative($comparative)
53
    {
54 1
        $this->comparative = $comparative;
55
56 1
        return $this;
57
    }
58
59
    /**
60
     * @return string
61
     */
62 1
    public function getComparative()
63
    {
64 1
        return $this->comparative;
65
    }
66
67
    /**
68
     * @param $axisPoint
69
     *
70
     * @return $this
71
     */
72 1
    public function setAxisPoint($axisPoint)
73
    {
74 1
        $this->axisPoint = $axisPoint;
75
76 1
        return $this;
77
    }
78
79
    /**
80
     * @return array
81
     */
82 1
    public function getAxisPoint()
83
    {
84 1
        return $this->axisPoint;
85
    }
86
87
    /**
88
     * @param $label
89
     *
90
     * @return $this
91
     */
92 1
    public function setLabel($label)
93
    {
94 1
        $this->label = $label;
95
96 1
        return $this;
97
    }
98
99
    /**
100
     */
101 1
    public function getLabel()
102
    {
103 1
        return $this->label;
104
    }
105
106
    /**
107
     * @param $measure
108
     *
109
     * @return $this
110
     */
111 1
    public function setMeasure($measure)
112
    {
113 1
        $this->measure = $measure;
114
115 1
        return $this;
116
    }
117
118
    /**
119
     * @return mixed
120
     */
121 1
    public function getMeasure()
122
    {
123 1
        return $this->measure;
124
    }
125
126
    /**
127
     * @param $range
128
     *
129
     * @return $this
130
     */
131 1
    public function setRange($range)
132
    {
133 1
        $this->range = $range;
134
135 1
        return $this;
136
    }
137
138
    /**
139
     * @return mixed
140
     */
141 1
    public function getRange()
142
    {
143 1
        return $this->range;
144
    }
145
146
    /**
147
     * @param $sublabel
148
     *
149
     * @return $this
150
     */
151 1
    public function setSublabel($sublabel)
152
    {
153 1
        $this->sublabel = $sublabel;
154
155 1
        return $this;
156
    }
157
158
    /**
159
     */
160 1
    public function getSublabel()
161
    {
162 1
        return $this->sublabel;
163
    }
164
165
    /**
166
     * @return array
167
     */
168 1
    public function toArray()
169
    {
170 1
        $result = array();
171 1
        $label = $this->getLabel();
172 1
        if (null !== $label) {
173 1
            $result['label'] = $label;
174 1
        }
175
176 1
        $sublabel = $this->getSublabel();
177 1
        if (null !== $sublabel) {
178 1
            $result['sublabel'] = $sublabel;
179 1
        }
180
181 1
        $result['axis']['point'] = $this->getAxisPoint();
182 1
        $result['range'] = $this->getRange();
183 1
        $result['measure'] = $this->getMeasure();
184 1
        $result['comparative']['point'] = $this->getComparative();
185
186 1
        return $result;
187
    }
188
}
189