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

HighchartsLabels::getOverflow()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
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 labels.
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 HighchartsLabels implements JsonSerializable {
26
27
    /**
28
     * Align.
29
     *
30
     * @var string
31
     */
32
    private $align = "right";
33
34
    /**
35
     * Auto rotation.
36
     *
37
     * @var array
38
     * @since 4.1.0
39
     */
40
    private $autoRotation = [-45];
41
42
    /**
43
     * Auto rotation limit.
44
     *
45
     * @var integer
46
     * @since 4.1.5
47
     */
48
    private $autoRotationLimit = 80;
49
50
    /**
51
     * Distance.
52
     *
53
     * @var integer
54
     */
55
    private $distance = -25;
56
57
    /**
58
     * Enabled.
59
     *
60
     * @var boolean
61
     */
62
    private $enabled = true;
63
64
    /**
65
     * Format.
66
     *
67
     * @var string
68
     * @since 3.0
69
     */
70
    private $format = "{value}";
71
72
    /**
73
     * Formatter.
74
     *
75
     * @var string
76
     */
77
    private $formatter;
78
79
    /**
80
     * Overflow.
81
     *
82
     * @var string
83
     * @since 2.2.5
84
     * @deprecated
85
     */
86
    private $overflow;
87
88
    /**
89
     * Padding.
90
     *
91
     * @var integer
92
     */
93
    private $padding = 5;
94
95
    /**
96
     * Reserve space.
97
     *
98
     * @var boolean
99
     * @since 4.1.10
100
     */
101
    private $reserveSpace = true;
102
103
    /**
104
     * Rotation.
105
     *
106
     * @var integer
107
     */
108
    private $rotation = 0;
109
110
    /**
111
     * Stagger lines.
112
     *
113
     * @var integer
114
     * @since 2.1
115
     */
116
    private $staggerLines;
117
118
    /**
119
     * Step.
120
     *
121
     * @var integer
122
     * @since 2.1
123
     */
124
    private $step;
125
126
    /**
127
     * Style.
128
     *
129
     * @var array
130
     */
131
    private $style = ["color" => "#666666", "cursor" => "default", "fontSize" => "11px"];
132
133
    /**
134
     * Use HTML.
135
     *
136
     * @var boolean
137
     */
138
    private $useHTML = false;
139
140
    /**
141
     * X.
142
     *
143
     * @var integer
144
     */
145
    private $x;
146
147
    /**
148
     * Y.
149
     *
150
     * @var integer
151
     */
152
    private $y = 3;
153
154
    /**
155
     * Z index.
156
     *
157
     * @var integer
158
     */
159
    private $zIndex = 7;
160
161
    /**
162
     * Constructor.
163
     *
164
     * @param boolean $ignoreDefaultValues Ignore the default values.
165
     */
166
    public function __construct($ignoreDefaultValues = true) {
167
        if (true === $ignoreDefaultValues) {
168
            $this->clear();
169
        }
170
    }
171
172
    /**
173
     * Clear.
174
     *
175
     * @return void
176
     */
177
    public function clear() {
178
179
        // Clear the align.
180
        $this->align = null;
181
182
        // Clear the auto rotation.
183
        $this->autoRotation = 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 $autoRotation.

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...
184
185
        // Clear the auto rotation limit.
186
        $this->autoRotationLimit = null;
187
188
        // Clear the distance.
189
        $this->distance = null;
190
191
        // Clear the enabled.
192
        $this->enabled = null;
193
194
        // Clear the format.
195
        $this->format = null;
196
197
        // Clear the formatter.
198
        $this->formatter = null;
199
200
        // Clear the overflow.
201
        $this->overflow = null;
0 ignored issues
show
Deprecated Code introduced by
The property WBW\Bundle\HighchartsBun...chartsLabels::$overflow has been deprecated.

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
202
203
        // Clear the padding.
204
        $this->padding = null;
205
206
        // Clear the reserve space.
207
        $this->reserveSpace = null;
208
209
        // Clear the rotation.
210
        $this->rotation = null;
211
212
        // Clear the stagger lines.
213
        $this->staggerLines = null;
214
215
        // Clear the step.
216
        $this->step = null;
217
218
        // Clear the style.
219
        $this->style = 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 $style.

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...
220
221
        // Clear the use HTML.
222
        $this->useHTML = null;
223
224
        // Clear the x.
225
        $this->x = null;
226
227
        // Clear the y.
228
        $this->y = null;
229
230
        // Clear the z index.
231
        $this->zIndex = null;
232
    }
233
234
    /**
235
     * Get the align.
236
     *
237
     * @return string Returns the align.
238
     */
239
    public function getAlign() {
240
        return $this->align;
241
    }
242
243
    /**
244
     * Get the auto rotation.
245
     *
246
     * @return array Returns the auto rotation.
247
     */
248
    public function getAutoRotation() {
249
        return $this->autoRotation;
250
    }
251
252
    /**
253
     * Get the auto rotation limit.
254
     *
255
     * @return integer Returns the auto rotation limit.
256
     */
257
    public function getAutoRotationLimit() {
258
        return $this->autoRotationLimit;
259
    }
260
261
    /**
262
     * Get the distance.
263
     *
264
     * @return integer Returns the distance.
265
     */
266
    public function getDistance() {
267
        return $this->distance;
268
    }
269
270
    /**
271
     * Get the enabled.
272
     *
273
     * @return boolean Returns the enabled.
274
     */
275
    public function getEnabled() {
276
        return $this->enabled;
277
    }
278
279
    /**
280
     * Get the format.
281
     *
282
     * @return string Returns the format.
283
     */
284
    public function getFormat() {
285
        return $this->format;
286
    }
287
288
    /**
289
     * Get the formatter.
290
     *
291
     * @return string Returns the formatter.
292
     */
293
    public function getFormatter() {
294
        return $this->formatter;
295
    }
296
297
    /**
298
     * Get the overflow.
299
     *
300
     * @return string Returns the overflow.
301
     * @deprecated
302
     */
303
    public function getOverflow() {
304
        return $this->overflow;
0 ignored issues
show
Deprecated Code introduced by
The property WBW\Bundle\HighchartsBun...chartsLabels::$overflow has been deprecated.

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
305
    }
306
307
    /**
308
     * Get the padding.
309
     *
310
     * @return integer Returns the padding.
311
     */
312
    public function getPadding() {
313
        return $this->padding;
314
    }
315
316
    /**
317
     * Get the reserve space.
318
     *
319
     * @return boolean Returns the reserve space.
320
     */
321
    public function getReserveSpace() {
322
        return $this->reserveSpace;
323
    }
324
325
    /**
326
     * Get the rotation.
327
     *
328
     * @return integer Returns the rotation.
329
     */
330
    public function getRotation() {
331
        return $this->rotation;
332
    }
333
334
    /**
335
     * Get the stagger lines.
336
     *
337
     * @return integer Returns the stagger lines.
338
     */
339
    public function getStaggerLines() {
340
        return $this->staggerLines;
341
    }
342
343
    /**
344
     * Get the step.
345
     *
346
     * @return integer Returns the step.
347
     */
348
    public function getStep() {
349
        return $this->step;
350
    }
351
352
    /**
353
     * Get the style.
354
     *
355
     * @return array Returns the style.
356
     */
357
    public function getStyle() {
358
        return $this->style;
359
    }
360
361
    /**
362
     * Get the use HTML.
363
     *
364
     * @return boolean Returns the use HTML.
365
     */
366
    public function getUseHTML() {
367
        return $this->useHTML;
368
    }
369
370
    /**
371
     * Get the x.
372
     *
373
     * @return integer Returns the x.
374
     */
375
    public function getX() {
376
        return $this->x;
377
    }
378
379
    /**
380
     * Get the y.
381
     *
382
     * @return integer Returns the y.
383
     */
384
    public function getY() {
385
        return $this->y;
386
    }
387
388
    /**
389
     * Get the z index.
390
     *
391
     * @return integer Returns the z index.
392
     */
393
    public function getZIndex() {
394
        return $this->zIndex;
395
    }
396
397
    /**
398
     * Serialize this instance.
399
     *
400
     * @return array Returns an array representing this instance.
401
     */
402
    public function jsonSerialize() {
403
        return $this->toArray();
404
    }
405
406
    /**
407
     * Set the align.
408
     *
409
     * @param string $align The align.
410
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\YAxis\HighchartsLabels Returns the highcharts labels.
411
     */
412
    public function setAlign($align) {
413
        switch ($align) {
414
            case "center":
415
            case "left":
416
            case "right":
417
            $this->align = $align;
418
            break;
419
        }
420
        return $this;
421
    }
422
423
    /**
424
     * Set the auto rotation.
425
     *
426
     * @param array $autoRotation The auto rotation.
427
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\YAxis\HighchartsLabels Returns the highcharts labels.
428
     */
429
    public function setAutoRotation(array $autoRotation = null) {
430
        $this->autoRotation = $autoRotation;
0 ignored issues
show
Documentation Bug introduced by
It seems like $autoRotation can be null. However, the property $autoRotation 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...
431
        return $this;
432
    }
433
434
    /**
435
     * Set the auto rotation limit.
436
     *
437
     * @param integer $autoRotationLimit The auto rotation limit.
438
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\YAxis\HighchartsLabels Returns the highcharts labels.
439
     */
440
    public function setAutoRotationLimit($autoRotationLimit) {
441
        $this->autoRotationLimit = $autoRotationLimit;
442
        return $this;
443
    }
444
445
    /**
446
     * Set the distance.
447
     *
448
     * @param integer $distance The distance.
449
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\YAxis\HighchartsLabels Returns the highcharts labels.
450
     */
451
    public function setDistance($distance) {
452
        $this->distance = $distance;
453
        return $this;
454
    }
455
456
    /**
457
     * Set the enabled.
458
     *
459
     * @param boolean $enabled The enabled.
460
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\YAxis\HighchartsLabels Returns the highcharts labels.
461
     */
462
    public function setEnabled($enabled) {
463
        $this->enabled = $enabled;
464
        return $this;
465
    }
466
467
    /**
468
     * Set the format.
469
     *
470
     * @param string $format The format.
471
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\YAxis\HighchartsLabels Returns the highcharts labels.
472
     */
473
    public function setFormat($format) {
474
        $this->format = $format;
475
        return $this;
476
    }
477
478
    /**
479
     * Set the formatter.
480
     *
481
     * @param string $formatter The formatter.
482
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\YAxis\HighchartsLabels Returns the highcharts labels.
483
     */
484
    public function setFormatter($formatter) {
485
        $this->formatter = $formatter;
486
        return $this;
487
    }
488
489
    /**
490
     * Set the overflow.
491
     *
492
     * @param string $overflow The overflow.
493
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\YAxis\HighchartsLabels Returns the highcharts labels.
494
     * @deprecated
495
     */
496
    public function setOverflow($overflow) {
497
        switch ($overflow) {
498
            case null:
499
            case "justify":
500
            $this->overflow = $overflow;
0 ignored issues
show
Deprecated Code introduced by
The property WBW\Bundle\HighchartsBun...chartsLabels::$overflow has been deprecated.

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
501
            break;
502
        }
503
        return $this;
504
    }
505
506
    /**
507
     * Set the padding.
508
     *
509
     * @param integer $padding The padding.
510
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\YAxis\HighchartsLabels Returns the highcharts labels.
511
     */
512
    public function setPadding($padding) {
513
        $this->padding = $padding;
514
        return $this;
515
    }
516
517
    /**
518
     * Set the reserve space.
519
     *
520
     * @param boolean $reserveSpace The reserve space.
521
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\YAxis\HighchartsLabels Returns the highcharts labels.
522
     */
523
    public function setReserveSpace($reserveSpace) {
524
        $this->reserveSpace = $reserveSpace;
525
        return $this;
526
    }
527
528
    /**
529
     * Set the rotation.
530
     *
531
     * @param integer $rotation The rotation.
532
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\YAxis\HighchartsLabels Returns the highcharts labels.
533
     */
534
    public function setRotation($rotation) {
535
        $this->rotation = $rotation;
536
        return $this;
537
    }
538
539
    /**
540
     * Set the stagger lines.
541
     *
542
     * @param integer $staggerLines The stagger lines.
543
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\YAxis\HighchartsLabels Returns the highcharts labels.
544
     */
545
    public function setStaggerLines($staggerLines) {
546
        $this->staggerLines = $staggerLines;
547
        return $this;
548
    }
549
550
    /**
551
     * Set the step.
552
     *
553
     * @param integer $step The step.
554
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\YAxis\HighchartsLabels Returns the highcharts labels.
555
     */
556
    public function setStep($step) {
557
        $this->step = $step;
558
        return $this;
559
    }
560
561
    /**
562
     * Set the style.
563
     *
564
     * @param array $style The style.
565
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\YAxis\HighchartsLabels Returns the highcharts labels.
566
     */
567
    public function setStyle(array $style = null) {
568
        $this->style = $style;
0 ignored issues
show
Documentation Bug introduced by
It seems like $style can be null. However, the property $style 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...
569
        return $this;
570
    }
571
572
    /**
573
     * Set the use HTML.
574
     *
575
     * @param boolean $useHTML The use HTML.
576
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\YAxis\HighchartsLabels Returns the highcharts labels.
577
     */
578
    public function setUseHTML($useHTML) {
579
        $this->useHTML = $useHTML;
580
        return $this;
581
    }
582
583
    /**
584
     * Set the x.
585
     *
586
     * @param integer $x The x.
587
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\YAxis\HighchartsLabels Returns the highcharts labels.
588
     */
589
    public function setX($x) {
590
        $this->x = $x;
591
        return $this;
592
    }
593
594
    /**
595
     * Set the y.
596
     *
597
     * @param integer $y The y.
598
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\YAxis\HighchartsLabels Returns the highcharts labels.
599
     */
600
    public function setY($y) {
601
        $this->y = $y;
602
        return $this;
603
    }
604
605
    /**
606
     * Set the z index.
607
     *
608
     * @param integer $zIndex The z index.
609
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\YAxis\HighchartsLabels Returns the highcharts labels.
610
     */
611
    public function setZIndex($zIndex) {
612
        $this->zIndex = $zIndex;
613
        return $this;
614
    }
615
616
    /**
617
     * Convert into an array representing this instance.
618
     *
619
     * @return array Returns an array representing this instance.
620
     */
621
    public function toArray() {
622
623
        // Initialize the output.
624
        $output = [];
625
626
        // Set the align.
627
        ArrayUtility::set($output, "align", $this->align, [null]);
628
629
        // Set the auto rotation.
630
        ArrayUtility::set($output, "autoRotation", $this->autoRotation, [null]);
631
632
        // Set the auto rotation limit.
633
        ArrayUtility::set($output, "autoRotationLimit", $this->autoRotationLimit, [null]);
634
635
        // Set the distance.
636
        ArrayUtility::set($output, "distance", $this->distance, [null]);
637
638
        // Set the enabled.
639
        ArrayUtility::set($output, "enabled", $this->enabled, [null]);
640
641
        // Set the format.
642
        ArrayUtility::set($output, "format", $this->format, [null]);
643
644
        // Set the formatter.
645
        ArrayUtility::set($output, "formatter", $this->formatter, [null]);
646
647
        // Set the overflow.
648
        ArrayUtility::set($output, "overflow", $this->overflow, [null]);
0 ignored issues
show
Deprecated Code introduced by
The property WBW\Bundle\HighchartsBun...chartsLabels::$overflow has been deprecated.

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
649
650
        // Set the padding.
651
        ArrayUtility::set($output, "padding", $this->padding, [null]);
652
653
        // Set the reserve space.
654
        ArrayUtility::set($output, "reserveSpace", $this->reserveSpace, [null]);
655
656
        // Set the rotation.
657
        ArrayUtility::set($output, "rotation", $this->rotation, [null]);
658
659
        // Set the stagger lines.
660
        ArrayUtility::set($output, "staggerLines", $this->staggerLines, [null]);
661
662
        // Set the step.
663
        ArrayUtility::set($output, "step", $this->step, [null]);
664
665
        // Set the style.
666
        ArrayUtility::set($output, "style", $this->style, [null]);
667
668
        // Set the use HTML.
669
        ArrayUtility::set($output, "useHTML", $this->useHTML, [null]);
670
671
        // Set the x.
672
        ArrayUtility::set($output, "x", $this->x, [null]);
673
674
        // Set the y.
675
        ArrayUtility::set($output, "y", $this->y, [null]);
676
677
        // Set the z index.
678
        ArrayUtility::set($output, "zIndex", $this->zIndex, [null]);
679
680
        // Return the output.
681
        return $output;
682
    }
683
684
}
685