Completed
Pull Request — master (#1)
by
unknown
17:16
created

HighchartsData::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
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\Series\Waterfall;
13
14
use JsonSerializable;
15
use WBW\Library\Core\Utility\Argument\ArrayUtility;
16
17
/**
18
 * Highcharts data.
19
 *
20
 * @author webeweb <https://github.com/webeweb/>
21
 * @package WBW\Bundle\HighchartsBundle\API\Chart\Series\Waterfall
22
 * @version 5.0.14
23
 * @final
24
 */
25
final class HighchartsData 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
     * Color index.
44
     *
45
     * @var integer
46
     * @since 5.0.0
47
     */
48
    private $colorIndex;
49
50
    /**
51
     * Data labels.
52
     *
53
     * @var array
54
     */
55
    private $dataLabels;
56
57
    /**
58
     * Description.
59
     *
60
     * @var string
61
     * @since 5.0.0
62
     */
63
    private $description;
64
65
    /**
66
     * Drilldown.
67
     *
68
     * @var string
69
     * @since 3.0.8
70
     */
71
    private $drilldown;
72
73
    /**
74
     * Events.
75
     *
76
     * @var \WBW\Bundle\HighchartsBundle\API\Chart\Series\Waterfall\Data\HighchartsEvents
77
     */
78
    private $events;
79
80
    /**
81
     * Id.
82
     *
83
     * @var string
84
     * @since 1.2.0
85
     */
86
    private $id;
87
88
    /**
89
     * Is intermediate sum.
90
     *
91
     * @var boolean
92
     */
93
    private $isIntermediateSum = false;
94
95
    /**
96
     * Is sum.
97
     *
98
     * @var boolean
99
     */
100
    private $isSum = false;
101
102
    /**
103
     * Labelrank.
104
     *
105
     * @var integer
106
     */
107
    private $labelrank;
108
109
    /**
110
     * Name.
111
     *
112
     * @var string
113
     */
114
    private $name;
115
116
    /**
117
     * Selected.
118
     *
119
     * @var boolean
120
     */
121
    private $selected = false;
122
123
    /**
124
     * X.
125
     *
126
     * @var integer
127
     */
128
    private $x;
129
130
    /**
131
     * Y.
132
     *
133
     * @var integer
134
     */
135
    private $y;
136
137
    /**
138
     * Constructor.
139
     *
140
     * @param boolean $ignoreDefaultValues Ignore the default values.
141
     */
142
    public function __construct($ignoreDefaultValues = true) {
143
        if (true === $ignoreDefaultValues) {
144
            $this->clear();
145
        }
146
    }
147
148
    /**
149
     * Clear.
150
     *
151
     * @return void
152
     */
153
    public function clear() {
154
155
        // Clear the class name.
156
        $this->className = null;
157
158
        // Clear the color.
159
        $this->color = null;
160
161
        // Clear the color index.
162
        $this->colorIndex = null;
163
164
        // Clear the data labels.
165
        $this->dataLabels = 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 $dataLabels.

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...
166
167
        // Clear the description.
168
        $this->description = null;
169
170
        // Clear the drilldown.
171
        $this->drilldown = null;
172
173
        // Clear the events.
174
        if (null !== $this->events) {
175
            $this->events->clear();
176
        }
177
178
        // Clear the id.
179
        $this->id = null;
180
181
        // Clear the is intermediate sum.
182
        $this->isIntermediateSum = null;
183
184
        // Clear the is sum.
185
        $this->isSum = null;
186
187
        // Clear the labelrank.
188
        $this->labelrank = null;
189
190
        // Clear the name.
191
        $this->name = null;
192
193
        // Clear the selected.
194
        $this->selected = null;
195
196
        // Clear the x.
197
        $this->x = null;
198
199
        // Clear the y.
200
        $this->y = null;
201
    }
202
203
    /**
204
     * Get the class name.
205
     *
206
     * @return string Returns the class name.
207
     */
208
    public function getClassName() {
209
        return $this->className;
210
    }
211
212
    /**
213
     * Get the color.
214
     *
215
     * @return string Returns the color.
216
     */
217
    public function getColor() {
218
        return $this->color;
219
    }
220
221
    /**
222
     * Get the color index.
223
     *
224
     * @return integer Returns the color index.
225
     */
226
    public function getColorIndex() {
227
        return $this->colorIndex;
228
    }
229
230
    /**
231
     * Get the data labels.
232
     *
233
     * @return array Returns the data labels.
234
     */
235
    public function getDataLabels() {
236
        return $this->dataLabels;
237
    }
238
239
    /**
240
     * Get the description.
241
     *
242
     * @return string Returns the description.
243
     */
244
    public function getDescription() {
245
        return $this->description;
246
    }
247
248
    /**
249
     * Get the drilldown.
250
     *
251
     * @return string Returns the drilldown.
252
     */
253
    public function getDrilldown() {
254
        return $this->drilldown;
255
    }
256
257
    /**
258
     * Get the events.
259
     *
260
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\Series\Waterfall\Data\HighchartsEvents Returns the events.
261
     */
262
    public function getEvents() {
263
        return $this->events;
264
    }
265
266
    /**
267
     * Get the id.
268
     *
269
     * @return string Returns the id.
270
     */
271
    public function getId() {
272
        return $this->id;
273
    }
274
275
    /**
276
     * Get the is intermediate sum.
277
     *
278
     * @return boolean Returns the is intermediate sum.
279
     */
280
    public function getIntermediateSum() {
281
        return $this->isIntermediateSum;
282
    }
283
284
    /**
285
     * Get the is sum.
286
     *
287
     * @return boolean Returns the is sum.
288
     */
289
    public function getSum() {
290
        return $this->isSum;
291
    }
292
293
    /**
294
     * Get the labelrank.
295
     *
296
     * @return integer Returns the labelrank.
297
     */
298
    public function getLabelrank() {
299
        return $this->labelrank;
300
    }
301
302
    /**
303
     * Get the name.
304
     *
305
     * @return string Returns the name.
306
     */
307
    public function getName() {
308
        return $this->name;
309
    }
310
311
    /**
312
     * Get the selected.
313
     *
314
     * @return boolean Returns the selected.
315
     */
316
    public function getSelected() {
317
        return $this->selected;
318
    }
319
320
    /**
321
     * Get the x.
322
     *
323
     * @return integer Returns the x.
324
     */
325
    public function getX() {
326
        return $this->x;
327
    }
328
329
    /**
330
     * Get the y.
331
     *
332
     * @return integer Returns the y.
333
     */
334
    public function getY() {
335
        return $this->y;
336
    }
337
338
    /**
339
     * Serialize this instance.
340
     *
341
     * @return array Returns an array representing this instance.
342
     */
343
    public function jsonSerialize() {
344
        return $this->toArray();
345
    }
346
347
    /**
348
     * Create a new events.
349
     *
350
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\Series\Waterfall\Data\HighchartsEvents Returns the events.
351
     */
352
    public function newEvents() {
353
        $this->events = new \WBW\Bundle\HighchartsBundle\API\Chart\Series\Waterfall\Data\HighchartsEvents();
354
        return $this->events;
355
    }
356
357
    /**
358
     * Set the class name.
359
     *
360
     * @param string $className The class name.
361
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\Series\Waterfall\HighchartsData Returns the highcharts data.
362
     */
363
    public function setClassName($className) {
364
        $this->className = $className;
365
        return $this;
366
    }
367
368
    /**
369
     * Set the color.
370
     *
371
     * @param string $color The color.
372
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\Series\Waterfall\HighchartsData Returns the highcharts data.
373
     */
374
    public function setColor($color) {
375
        $this->color = $color;
376
        return $this;
377
    }
378
379
    /**
380
     * Set the color index.
381
     *
382
     * @param integer $colorIndex The color index.
383
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\Series\Waterfall\HighchartsData Returns the highcharts data.
384
     */
385
    public function setColorIndex($colorIndex) {
386
        $this->colorIndex = $colorIndex;
387
        return $this;
388
    }
389
390
    /**
391
     * Set the data labels.
392
     *
393
     * @param array $dataLabels The data labels.
394
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\Series\Waterfall\HighchartsData Returns the highcharts data.
395
     */
396
    public function setDataLabels(array $dataLabels = null) {
397
        $this->dataLabels = $dataLabels;
0 ignored issues
show
Documentation Bug introduced by
It seems like $dataLabels can be null. However, the property $dataLabels 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...
398
        return $this;
399
    }
400
401
    /**
402
     * Set the description.
403
     *
404
     * @param string $description The description.
405
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\Series\Waterfall\HighchartsData Returns the highcharts data.
406
     */
407
    public function setDescription($description) {
408
        $this->description = $description;
409
        return $this;
410
    }
411
412
    /**
413
     * Set the drilldown.
414
     *
415
     * @param string $drilldown The drilldown.
416
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\Series\Waterfall\HighchartsData Returns the highcharts data.
417
     */
418
    public function setDrilldown($drilldown) {
419
        $this->drilldown = $drilldown;
420
        return $this;
421
    }
422
423
    /**
424
     * Set the events.
425
     *
426
     * @param \WBW\Bundle\HighchartsBundle\API\Chart\Series\Waterfall\Data\HighchartsEvents $events The events.
427
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\Series\Waterfall\HighchartsData Returns the highcharts data.
428
     */
429
    public function setEvents(\WBW\Bundle\HighchartsBundle\API\Chart\Series\Waterfall\Data\HighchartsEvents $events = null) {
430
        $this->events = $events;
431
        return $this;
432
    }
433
434
    /**
435
     * Set the id.
436
     *
437
     * @param string $id The id.
438
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\Series\Waterfall\HighchartsData Returns the highcharts data.
439
     */
440
    public function setId($id) {
441
        $this->id = $id;
442
        return $this;
443
    }
444
445
    /**
446
     * Set the is intermediate sum.
447
     *
448
     * @param boolean $isIntermediateSum The is intermediate sum.
449
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\Series\Waterfall\HighchartsData Returns the highcharts data.
450
     */
451
    public function setIntermediateSum($isIntermediateSum) {
452
        $this->isIntermediateSum = $isIntermediateSum;
453
        return $this;
454
    }
455
456
    /**
457
     * Set the is sum.
458
     *
459
     * @param boolean $isSum The is sum.
460
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\Series\Waterfall\HighchartsData Returns the highcharts data.
461
     */
462
    public function setSum($isSum) {
463
        $this->isSum = $isSum;
464
        return $this;
465
    }
466
467
    /**
468
     * Set the labelrank.
469
     *
470
     * @param integer $labelrank The labelrank.
471
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\Series\Waterfall\HighchartsData Returns the highcharts data.
472
     */
473
    public function setLabelrank($labelrank) {
474
        $this->labelrank = $labelrank;
475
        return $this;
476
    }
477
478
    /**
479
     * Set the name.
480
     *
481
     * @param string $name The name.
482
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\Series\Waterfall\HighchartsData Returns the highcharts data.
483
     */
484
    public function setName($name) {
485
        $this->name = $name;
486
        return $this;
487
    }
488
489
    /**
490
     * Set the selected.
491
     *
492
     * @param boolean $selected The selected.
493
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\Series\Waterfall\HighchartsData Returns the highcharts data.
494
     */
495
    public function setSelected($selected) {
496
        $this->selected = $selected;
497
        return $this;
498
    }
499
500
    /**
501
     * Set the x.
502
     *
503
     * @param integer $x The x.
504
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\Series\Waterfall\HighchartsData Returns the highcharts data.
505
     */
506
    public function setX($x) {
507
        $this->x = $x;
508
        return $this;
509
    }
510
511
    /**
512
     * Set the y.
513
     *
514
     * @param integer $y The y.
515
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\Series\Waterfall\HighchartsData Returns the highcharts data.
516
     */
517
    public function setY($y) {
518
        $this->y = $y;
519
        return $this;
520
    }
521
522
    /**
523
     * Convert into an array representing this instance.
524
     *
525
     * @return array Returns an array representing this instance.
526
     */
527
    public function toArray() {
528
529
        // Initialize the output.
530
        $output = [];
531
532
        // Set the class name.
533
        ArrayUtility::set($output, "className", $this->className, [null]);
534
535
        // Set the color.
536
        ArrayUtility::set($output, "color", $this->color, [null]);
537
538
        // Set the color index.
539
        ArrayUtility::set($output, "colorIndex", $this->colorIndex, [null]);
540
541
        // Set the data labels.
542
        ArrayUtility::set($output, "dataLabels", $this->dataLabels, [null]);
543
544
        // Set the description.
545
        ArrayUtility::set($output, "description", $this->description, [null]);
546
547
        // Set the drilldown.
548
        ArrayUtility::set($output, "drilldown", $this->drilldown, [null]);
549
550
        // Set the events.
551
        if (null !== $this->events) {
552
            ArrayUtility::set($output, "events", $this->events->toArray(), []);
553
        }
554
555
        // Set the id.
556
        ArrayUtility::set($output, "id", $this->id, [null]);
557
558
        // Set the is intermediate sum.
559
        ArrayUtility::set($output, "isIntermediateSum", $this->isIntermediateSum, [null]);
560
561
        // Set the is sum.
562
        ArrayUtility::set($output, "isSum", $this->isSum, [null]);
563
564
        // Set the labelrank.
565
        ArrayUtility::set($output, "labelrank", $this->labelrank, [null]);
566
567
        // Set the name.
568
        ArrayUtility::set($output, "name", $this->name, [null]);
569
570
        // Set the selected.
571
        ArrayUtility::set($output, "selected", $this->selected, [null]);
572
573
        // Set the x.
574
        ArrayUtility::set($output, "x", $this->x, [null]);
575
576
        // Set the y.
577
        ArrayUtility::set($output, "y", $this->y, [null]);
578
579
        // Return the output.
580
        return $output;
581
    }
582
583
}
584