HighchartsPlotBands   A
last analyzed

Complexity

Total Complexity 34

Size/Duplication

Total Lines 494
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 34
lcom 1
cbo 2
dl 0
loc 494
rs 9.68
c 0
b 0
f 0

31 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 2
A clear() 0 43 2
A getBorderColor() 0 3 1
A getBorderWidth() 0 3 1
A getClassName() 0 3 1
A getColor() 0 3 1
A getEvents() 0 3 1
A getFrom() 0 3 1
A getId() 0 3 1
A getInnerRadius() 0 3 1
A getLabel() 0 3 1
A getOuterRadius() 0 3 1
A getThickness() 0 3 1
A getTo() 0 3 1
A getZIndex() 0 3 1
A jsonSerialize() 0 3 1
A newLabel() 0 4 1
A setBorderColor() 0 4 1
A setBorderWidth() 0 4 1
A setClassName() 0 4 1
A setColor() 0 4 1
A setEvents() 0 4 1
A setFrom() 0 4 1
A setId() 0 4 1
A setInnerRadius() 0 4 1
A setLabel() 0 4 1
A setOuterRadius() 0 4 1
A setThickness() 0 4 1
A setTo() 0 4 1
A setZIndex() 0 4 1
A toArray() 0 49 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\YAxis;
13
14
use JsonSerializable;
15
use WBW\Library\Core\Utility\Argument\ArrayUtility;
16
17
/**
18
 * Highcharts plot bands.
19
 *
20
 * @author webeweb <https://github.com/webeweb/>
21
 * @package WBW\Bundle\HighchartsBundle\API\Chart\YAxis
22
 * @version 5.0.14
23
 * @final
24
 */
25
final class HighchartsPlotBands implements JsonSerializable {
26
27
    /**
28
     * Border color.
29
     *
30
     * @var string
31
     */
32
    private $borderColor;
33
34
    /**
35
     * Border width.
36
     *
37
     * @var integer
38
     */
39
    private $borderWidth = 0;
40
41
    /**
42
     * Class name.
43
     *
44
     * @var string
45
     * @since 5.0.0
46
     */
47
    private $className;
48
49
    /**
50
     * Color.
51
     *
52
     * @var string
53
     */
54
    private $color;
55
56
    /**
57
     * Events.
58
     *
59
     * @var array
60
     * @since 1.2
61
     */
62
    private $events;
63
64
    /**
65
     * From.
66
     *
67
     * @var integer
68
     */
69
    private $from;
70
71
    /**
72
     * Id.
73
     *
74
     * @var string
75
     */
76
    private $id;
77
78
    /**
79
     * Inner radius.
80
     *
81
     * @var integer|string
82
     * @since 2.3
83
     */
84
    private $innerRadius;
85
86
    /**
87
     * Label.
88
     *
89
     * @var \WBW\Bundle\HighchartsBundle\API\Chart\YAxis\PlotBands\HighchartsLabel
90
     */
91
    private $label;
92
93
    /**
94
     * Outer radius.
95
     *
96
     * @var integer|string
97
     * @since 2.3
98
     */
99
    private $outerRadius = "100%";
100
101
    /**
102
     * Thickness.
103
     *
104
     * @var integer|string
105
     * @since 2.3
106
     */
107
    private $thickness = "10";
108
109
    /**
110
     * To.
111
     *
112
     * @var integer
113
     */
114
    private $to;
115
116
    /**
117
     * Z index.
118
     *
119
     * @var integer
120
     * @since 1.2
121
     */
122
    private $zIndex;
123
124
    /**
125
     * Constructor.
126
     *
127
     * @param boolean $ignoreDefaultValues Ignore the default values.
128
     */
129
    public function __construct($ignoreDefaultValues = true) {
130
        if (true === $ignoreDefaultValues) {
131
            $this->clear();
132
        }
133
    }
134
135
    /**
136
     * Clear.
137
     *
138
     * @return void
139
     */
140
    public function clear() {
141
142
        // Clear the border color.
143
        $this->borderColor = null;
144
145
        // Clear the border width.
146
        $this->borderWidth = null;
147
148
        // Clear the class name.
149
        $this->className = null;
150
151
        // Clear the color.
152
        $this->color = null;
153
154
        // Clear the events.
155
        $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...
156
157
        // Clear the from.
158
        $this->from = null;
159
160
        // Clear the id.
161
        $this->id = null;
162
163
        // Clear the inner radius.
164
        $this->innerRadius = null;
165
166
        // Clear the label.
167
        if (null !== $this->label) {
168
            $this->label->clear();
169
        }
170
171
        // Clear the outer radius.
172
        $this->outerRadius = null;
173
174
        // Clear the thickness.
175
        $this->thickness = null;
176
177
        // Clear the to.
178
        $this->to = null;
179
180
        // Clear the z index.
181
        $this->zIndex = null;
182
    }
183
184
    /**
185
     * Get the border color.
186
     *
187
     * @return string Returns the border color.
188
     */
189
    public function getBorderColor() {
190
        return $this->borderColor;
191
    }
192
193
    /**
194
     * Get the border width.
195
     *
196
     * @return integer Returns the border width.
197
     */
198
    public function getBorderWidth() {
199
        return $this->borderWidth;
200
    }
201
202
    /**
203
     * Get the class name.
204
     *
205
     * @return string Returns the class name.
206
     */
207
    public function getClassName() {
208
        return $this->className;
209
    }
210
211
    /**
212
     * Get the color.
213
     *
214
     * @return string Returns the color.
215
     */
216
    public function getColor() {
217
        return $this->color;
218
    }
219
220
    /**
221
     * Get the events.
222
     *
223
     * @return array Returns the events.
224
     */
225
    public function getEvents() {
226
        return $this->events;
227
    }
228
229
    /**
230
     * Get the from.
231
     *
232
     * @return integer Returns the from.
233
     */
234
    public function getFrom() {
235
        return $this->from;
236
    }
237
238
    /**
239
     * Get the id.
240
     *
241
     * @return string Returns the id.
242
     */
243
    public function getId() {
244
        return $this->id;
245
    }
246
247
    /**
248
     * Get the inner radius.
249
     *
250
     * @return integer|string Returns the inner radius.
251
     */
252
    public function getInnerRadius() {
253
        return $this->innerRadius;
254
    }
255
256
    /**
257
     * Get the label.
258
     *
259
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\YAxis\PlotBands\HighchartsLabel Returns the label.
260
     */
261
    public function getLabel() {
262
        return $this->label;
263
    }
264
265
    /**
266
     * Get the outer radius.
267
     *
268
     * @return integer|string Returns the outer radius.
269
     */
270
    public function getOuterRadius() {
271
        return $this->outerRadius;
272
    }
273
274
    /**
275
     * Get the thickness.
276
     *
277
     * @return integer|string Returns the thickness.
278
     */
279
    public function getThickness() {
280
        return $this->thickness;
281
    }
282
283
    /**
284
     * Get the to.
285
     *
286
     * @return integer Returns the to.
287
     */
288
    public function getTo() {
289
        return $this->to;
290
    }
291
292
    /**
293
     * Get the z index.
294
     *
295
     * @return integer Returns the z index.
296
     */
297
    public function getZIndex() {
298
        return $this->zIndex;
299
    }
300
301
    /**
302
     * Serialize this instance.
303
     *
304
     * @return array Returns an array representing this instance.
305
     */
306
    public function jsonSerialize() {
307
        return $this->toArray();
308
    }
309
310
    /**
311
     * Create a new label.
312
     *
313
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\YAxis\PlotBands\HighchartsLabel Returns the label.
314
     */
315
    public function newLabel() {
316
        $this->label = new \WBW\Bundle\HighchartsBundle\API\Chart\YAxis\PlotBands\HighchartsLabel();
317
        return $this->label;
318
    }
319
320
    /**
321
     * Set the border color.
322
     *
323
     * @param string $borderColor The border color.
324
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\YAxis\HighchartsPlotBands Returns the highcharts plot bands.
325
     */
326
    public function setBorderColor($borderColor) {
327
        $this->borderColor = $borderColor;
328
        return $this;
329
    }
330
331
    /**
332
     * Set the border width.
333
     *
334
     * @param integer $borderWidth The border width.
335
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\YAxis\HighchartsPlotBands Returns the highcharts plot bands.
336
     */
337
    public function setBorderWidth($borderWidth) {
338
        $this->borderWidth = $borderWidth;
339
        return $this;
340
    }
341
342
    /**
343
     * Set the class name.
344
     *
345
     * @param string $className The class name.
346
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\YAxis\HighchartsPlotBands Returns the highcharts plot bands.
347
     */
348
    public function setClassName($className) {
349
        $this->className = $className;
350
        return $this;
351
    }
352
353
    /**
354
     * Set the color.
355
     *
356
     * @param string $color The color.
357
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\YAxis\HighchartsPlotBands Returns the highcharts plot bands.
358
     */
359
    public function setColor($color) {
360
        $this->color = $color;
361
        return $this;
362
    }
363
364
    /**
365
     * Set the events.
366
     *
367
     * @param array $events The events.
368
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\YAxis\HighchartsPlotBands Returns the highcharts plot bands.
369
     */
370
    public function setEvents(array $events = null) {
371
        $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...
372
        return $this;
373
    }
374
375
    /**
376
     * Set the from.
377
     *
378
     * @param integer $from The from.
379
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\YAxis\HighchartsPlotBands Returns the highcharts plot bands.
380
     */
381
    public function setFrom($from) {
382
        $this->from = $from;
383
        return $this;
384
    }
385
386
    /**
387
     * Set the id.
388
     *
389
     * @param string $id The id.
390
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\YAxis\HighchartsPlotBands Returns the highcharts plot bands.
391
     */
392
    public function setId($id) {
393
        $this->id = $id;
394
        return $this;
395
    }
396
397
    /**
398
     * Set the inner radius.
399
     *
400
     * @param integer|string $innerRadius The inner radius.
401
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\YAxis\HighchartsPlotBands Returns the highcharts plot bands.
402
     */
403
    public function setInnerRadius($innerRadius) {
404
        $this->innerRadius = $innerRadius;
405
        return $this;
406
    }
407
408
    /**
409
     * Set the label.
410
     *
411
     * @param \WBW\Bundle\HighchartsBundle\API\Chart\YAxis\PlotBands\HighchartsLabel $label The label.
412
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\YAxis\HighchartsPlotBands Returns the highcharts plot bands.
413
     */
414
    public function setLabel(\WBW\Bundle\HighchartsBundle\API\Chart\YAxis\PlotBands\HighchartsLabel $label = null) {
415
        $this->label = $label;
416
        return $this;
417
    }
418
419
    /**
420
     * Set the outer radius.
421
     *
422
     * @param integer|string $outerRadius The outer radius.
423
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\YAxis\HighchartsPlotBands Returns the highcharts plot bands.
424
     */
425
    public function setOuterRadius($outerRadius) {
426
        $this->outerRadius = $outerRadius;
427
        return $this;
428
    }
429
430
    /**
431
     * Set the thickness.
432
     *
433
     * @param integer|string $thickness The thickness.
434
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\YAxis\HighchartsPlotBands Returns the highcharts plot bands.
435
     */
436
    public function setThickness($thickness) {
437
        $this->thickness = $thickness;
438
        return $this;
439
    }
440
441
    /**
442
     * Set the to.
443
     *
444
     * @param integer $to The to.
445
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\YAxis\HighchartsPlotBands Returns the highcharts plot bands.
446
     */
447
    public function setTo($to) {
448
        $this->to = $to;
449
        return $this;
450
    }
451
452
    /**
453
     * Set the z index.
454
     *
455
     * @param integer $zIndex The z index.
456
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\YAxis\HighchartsPlotBands Returns the highcharts plot bands.
457
     */
458
    public function setZIndex($zIndex) {
459
        $this->zIndex = $zIndex;
460
        return $this;
461
    }
462
463
    /**
464
     * Convert into an array representing this instance.
465
     *
466
     * @return array Returns an array representing this instance.
467
     */
468
    public function toArray() {
469
470
        // Initialize the output.
471
        $output = [];
472
473
        // Set the border color.
474
        ArrayUtility::set($output, "borderColor", $this->borderColor, [null]);
475
476
        // Set the border width.
477
        ArrayUtility::set($output, "borderWidth", $this->borderWidth, [null]);
478
479
        // Set the class name.
480
        ArrayUtility::set($output, "className", $this->className, [null]);
481
482
        // Set the color.
483
        ArrayUtility::set($output, "color", $this->color, [null]);
484
485
        // Set the events.
486
        ArrayUtility::set($output, "events", $this->events, [null]);
487
488
        // Set the from.
489
        ArrayUtility::set($output, "from", $this->from, [null]);
490
491
        // Set the id.
492
        ArrayUtility::set($output, "id", $this->id, [null]);
493
494
        // Set the inner radius.
495
        ArrayUtility::set($output, "innerRadius", $this->innerRadius, [null]);
496
497
        // Set the label.
498
        if (null !== $this->label) {
499
            ArrayUtility::set($output, "label", $this->label->toArray(), []);
500
        }
501
502
        // Set the outer radius.
503
        ArrayUtility::set($output, "outerRadius", $this->outerRadius, [null]);
504
505
        // Set the thickness.
506
        ArrayUtility::set($output, "thickness", $this->thickness, [null]);
507
508
        // Set the to.
509
        ArrayUtility::set($output, "to", $this->to, [null]);
510
511
        // Set the z index.
512
        ArrayUtility::set($output, "zIndex", $this->zIndex, [null]);
513
514
        // Return the output.
515
        return $output;
516
    }
517
518
}
519