HighchartsPlotLines   A
last analyzed

Complexity

Total Complexity 37

Size/Duplication

Total Lines 374
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 37
lcom 1
cbo 2
dl 0
loc 374
rs 9.44
c 0
b 0
f 0

23 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 2
A clear() 0 31 2
A getClassName() 0 3 1
A getColor() 0 3 1
A getDashStyle() 0 3 1
A getEvents() 0 3 1
A getId() 0 3 1
A getLabel() 0 3 1
A getValue() 0 3 1
A getWidth() 0 3 1
A getZIndex() 0 3 1
A jsonSerialize() 0 3 1
A newLabel() 0 4 1
A setClassName() 0 4 1
A setColor() 0 4 1
C setDashStyle() 0 18 12
A setEvents() 0 4 1
A setId() 0 4 1
A setLabel() 0 4 1
A setValue() 0 4 1
A setWidth() 0 4 1
A setZIndex() 0 4 1
A toArray() 0 37 2
1
<?php
2
3
/**
4
 * This file is part of the highcharts-bundle package.
5
 *
6
 * (c) 2017 WEBEWEB
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace WBW\Bundle\HighchartsBundle\API\Chart\ZAxis;
13
14
use JsonSerializable;
15
use WBW\Library\Core\Utility\Argument\ArrayUtility;
16
17
/**
18
 * Highcharts plot lines.
19
 *
20
 * @author webeweb <https://github.com/webeweb/>
21
 * @package WBW\Bundle\HighchartsBundle\API\Chart\ZAxis
22
 * @version 5.0.14
23
 * @final
24
 */
25
final class HighchartsPlotLines implements JsonSerializable {
26
27
    /**
28
     * Class name.
29
     *
30
     * @var string
31
     * @since 5.0.0
32
     */
33
    private $className;
34
35
    /**
36
     * Color.
37
     *
38
     * @var string
39
     */
40
    private $color;
41
42
    /**
43
     * Dash style.
44
     *
45
     * @var string
46
     * @since 1.2
47
     */
48
    private $dashStyle = "Solid";
49
50
    /**
51
     * Events.
52
     *
53
     * @var array
54
     * @since 1.2
55
     */
56
    private $events;
57
58
    /**
59
     * Id.
60
     *
61
     * @var string
62
     */
63
    private $id;
64
65
    /**
66
     * Label.
67
     *
68
     * @var \WBW\Bundle\HighchartsBundle\API\Chart\ZAxis\PlotLines\HighchartsLabel
69
     */
70
    private $label;
71
72
    /**
73
     * Value.
74
     *
75
     * @var integer
76
     */
77
    private $value;
78
79
    /**
80
     * Width.
81
     *
82
     * @var integer
83
     */
84
    private $width;
85
86
    /**
87
     * Z index.
88
     *
89
     * @var integer
90
     * @since 1.2
91
     */
92
    private $zIndex;
93
94
    /**
95
     * Constructor.
96
     *
97
     * @param boolean $ignoreDefaultValues Ignore the default values.
98
     */
99
    public function __construct($ignoreDefaultValues = true) {
100
        if (true === $ignoreDefaultValues) {
101
            $this->clear();
102
        }
103
    }
104
105
    /**
106
     * Clear.
107
     *
108
     * @return void
109
     */
110
    public function clear() {
111
112
        // Clear the class name.
113
        $this->className = null;
114
115
        // Clear the color.
116
        $this->color = null;
117
118
        // Clear the dash style.
119
        $this->dashStyle = null;
120
121
        // Clear the events.
122
        $this->events = null;
0 ignored issues
show
Documentation Bug introduced by
It seems like null of type null is incompatible with the declared type array of property $events.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
123
124
        // Clear the id.
125
        $this->id = null;
126
127
        // Clear the label.
128
        if (null !== $this->label) {
129
            $this->label->clear();
130
        }
131
132
        // Clear the value.
133
        $this->value = null;
134
135
        // Clear the width.
136
        $this->width = null;
137
138
        // Clear the z index.
139
        $this->zIndex = null;
140
    }
141
142
    /**
143
     * Get the class name.
144
     *
145
     * @return string Returns the class name.
146
     */
147
    public function getClassName() {
148
        return $this->className;
149
    }
150
151
    /**
152
     * Get the color.
153
     *
154
     * @return string Returns the color.
155
     */
156
    public function getColor() {
157
        return $this->color;
158
    }
159
160
    /**
161
     * Get the dash style.
162
     *
163
     * @return string Returns the dash style.
164
     */
165
    public function getDashStyle() {
166
        return $this->dashStyle;
167
    }
168
169
    /**
170
     * Get the events.
171
     *
172
     * @return array Returns the events.
173
     */
174
    public function getEvents() {
175
        return $this->events;
176
    }
177
178
    /**
179
     * Get the id.
180
     *
181
     * @return string Returns the id.
182
     */
183
    public function getId() {
184
        return $this->id;
185
    }
186
187
    /**
188
     * Get the label.
189
     *
190
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\ZAxis\PlotLines\HighchartsLabel Returns the label.
191
     */
192
    public function getLabel() {
193
        return $this->label;
194
    }
195
196
    /**
197
     * Get the value.
198
     *
199
     * @return integer Returns the value.
200
     */
201
    public function getValue() {
202
        return $this->value;
203
    }
204
205
    /**
206
     * Get the width.
207
     *
208
     * @return integer Returns the width.
209
     */
210
    public function getWidth() {
211
        return $this->width;
212
    }
213
214
    /**
215
     * Get the z index.
216
     *
217
     * @return integer Returns the z index.
218
     */
219
    public function getZIndex() {
220
        return $this->zIndex;
221
    }
222
223
    /**
224
     * Serialize this instance.
225
     *
226
     * @return array Returns an array representing this instance.
227
     */
228
    public function jsonSerialize() {
229
        return $this->toArray();
230
    }
231
232
    /**
233
     * Create a new label.
234
     *
235
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\ZAxis\PlotLines\HighchartsLabel Returns the label.
236
     */
237
    public function newLabel() {
238
        $this->label = new \WBW\Bundle\HighchartsBundle\API\Chart\ZAxis\PlotLines\HighchartsLabel();
239
        return $this->label;
240
    }
241
242
    /**
243
     * Set the class name.
244
     *
245
     * @param string $className The class name.
246
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\ZAxis\HighchartsPlotLines Returns the highcharts plot lines.
247
     */
248
    public function setClassName($className) {
249
        $this->className = $className;
250
        return $this;
251
    }
252
253
    /**
254
     * Set the color.
255
     *
256
     * @param string $color The color.
257
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\ZAxis\HighchartsPlotLines Returns the highcharts plot lines.
258
     */
259
    public function setColor($color) {
260
        $this->color = $color;
261
        return $this;
262
    }
263
264
    /**
265
     * Set the dash style.
266
     *
267
     * @param string $dashStyle The dash style.
268
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\ZAxis\HighchartsPlotLines Returns the highcharts plot lines.
269
     */
270
    public function setDashStyle($dashStyle) {
271
        switch ($dashStyle) {
272
            case "Dash":
273
            case "DashDot":
274
            case "Dot":
275
            case "LongDash":
276
            case "LongDashDot":
277
            case "LongDashDotDot":
278
            case "ShortDash":
279
            case "ShortDashDot":
280
            case "ShortDashDotDot":
281
            case "ShortDot":
282
            case "Solid":
283
            $this->dashStyle = $dashStyle;
284
            break;
285
        }
286
        return $this;
287
    }
288
289
    /**
290
     * Set the events.
291
     *
292
     * @param array $events The events.
293
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\ZAxis\HighchartsPlotLines Returns the highcharts plot lines.
294
     */
295
    public function setEvents(array $events = null) {
296
        $this->events = $events;
0 ignored issues
show
Documentation Bug introduced by
It seems like $events can be null. However, the property $events is declared as array. Maybe change the type of the property to array|null or add a type check?

Our type inference engine has found an assignment of a scalar value (like a string, an integer or null) to a property which is an array.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property.

To type hint that a parameter can be either an array or null, you can set a type hint of array and a default value of null. The PHP interpreter will then accept both an array or null for that parameter.

function aContainsB(array $needle = null, array  $haystack) {
    if (!$needle) {
        return false;
    }

    return array_intersect($haystack, $needle) == $haystack;
}

The function can be called with either null or an array for the parameter $needle but will only accept an array as $haystack.

Loading history...
297
        return $this;
298
    }
299
300
    /**
301
     * Set the id.
302
     *
303
     * @param string $id The id.
304
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\ZAxis\HighchartsPlotLines Returns the highcharts plot lines.
305
     */
306
    public function setId($id) {
307
        $this->id = $id;
308
        return $this;
309
    }
310
311
    /**
312
     * Set the label.
313
     *
314
     * @param \WBW\Bundle\HighchartsBundle\API\Chart\ZAxis\PlotLines\HighchartsLabel $label The label.
315
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\ZAxis\HighchartsPlotLines Returns the highcharts plot lines.
316
     */
317
    public function setLabel(\WBW\Bundle\HighchartsBundle\API\Chart\ZAxis\PlotLines\HighchartsLabel $label = null) {
318
        $this->label = $label;
319
        return $this;
320
    }
321
322
    /**
323
     * Set the value.
324
     *
325
     * @param integer $value The value.
326
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\ZAxis\HighchartsPlotLines Returns the highcharts plot lines.
327
     */
328
    public function setValue($value) {
329
        $this->value = $value;
330
        return $this;
331
    }
332
333
    /**
334
     * Set the width.
335
     *
336
     * @param integer $width The width.
337
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\ZAxis\HighchartsPlotLines Returns the highcharts plot lines.
338
     */
339
    public function setWidth($width) {
340
        $this->width = $width;
341
        return $this;
342
    }
343
344
    /**
345
     * Set the z index.
346
     *
347
     * @param integer $zIndex The z index.
348
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\ZAxis\HighchartsPlotLines Returns the highcharts plot lines.
349
     */
350
    public function setZIndex($zIndex) {
351
        $this->zIndex = $zIndex;
352
        return $this;
353
    }
354
355
    /**
356
     * Convert into an array representing this instance.
357
     *
358
     * @return array Returns an array representing this instance.
359
     */
360
    public function toArray() {
361
362
        // Initialize the output.
363
        $output = [];
364
365
        // Set the class name.
366
        ArrayUtility::set($output, "className", $this->className, [null]);
367
368
        // Set the color.
369
        ArrayUtility::set($output, "color", $this->color, [null]);
370
371
        // Set the dash style.
372
        ArrayUtility::set($output, "dashStyle", $this->dashStyle, [null]);
373
374
        // Set the events.
375
        ArrayUtility::set($output, "events", $this->events, [null]);
376
377
        // Set the id.
378
        ArrayUtility::set($output, "id", $this->id, [null]);
379
380
        // Set the label.
381
        if (null !== $this->label) {
382
            ArrayUtility::set($output, "label", $this->label->toArray(), []);
383
        }
384
385
        // Set the value.
386
        ArrayUtility::set($output, "value", $this->value, [null]);
387
388
        // Set the width.
389
        ArrayUtility::set($output, "width", $this->width, [null]);
390
391
        // Set the z index.
392
        ArrayUtility::set($output, "zIndex", $this->zIndex, [null]);
393
394
        // Return the output.
395
        return $output;
396
    }
397
398
}
399