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

HighchartsContextButton::setSymbolY()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
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\Exporting\Buttons;
13
14
use JsonSerializable;
15
use WBW\Library\Core\Utility\Argument\ArrayUtility;
16
17
/**
18
 * Highcharts context button.
19
 *
20
 * @author webeweb <https://github.com/webeweb/>
21
 * @package WBW\Bundle\HighchartsBundle\API\Chart\Exporting\Buttons
22
 * @version 5.0.14
23
 * @final
24
 */
25
final class HighchartsContextButton implements JsonSerializable {
26
27
    /**
28
     * Align.
29
     *
30
     * @var string
31
     * @since 2.0
32
     */
33
    private $align = "right";
34
35
    /**
36
     * Enabled.
37
     *
38
     * @var boolean
39
     * @since 2.0
40
     */
41
    private $enabled = true;
42
43
    /**
44
     * Height.
45
     *
46
     * @var integer
47
     * @since 2.0
48
     */
49
    private $height = 20;
50
51
    /**
52
     * Menu items.
53
     *
54
     * @var array
55
     * @since 2.0
56
     */
57
    private $menuItems;
58
59
    /**
60
     * Onclick.
61
     *
62
     * @var string
63
     * @since 2.0
64
     */
65
    private $onclick;
66
67
    /**
68
     * Symbol.
69
     *
70
     * @var string
71
     * @since 2.0
72
     */
73
    private $symbol = "menu";
74
75
    /**
76
     * Symbol fill.
77
     *
78
     * @var string
79
     * @since 2.0
80
     */
81
    private $symbolFill = "#666666";
82
83
    /**
84
     * Symbol size.
85
     *
86
     * @var integer
87
     * @since 2.0
88
     */
89
    private $symbolSize = 14;
90
91
    /**
92
     * Symbol stroke.
93
     *
94
     * @var string
95
     * @since 2.0
96
     */
97
    private $symbolStroke = "#666666";
98
99
    /**
100
     * Symbol stroke width.
101
     *
102
     * @var integer
103
     * @since 2.0
104
     */
105
    private $symbolStrokeWidth = 1;
106
107
    /**
108
     * Symbol x.
109
     *
110
     * @var integer
111
     * @since 2.0
112
     */
113
    private $symbolX = 12.5;
114
115
    /**
116
     * Symbol y.
117
     *
118
     * @var integer
119
     * @since 2.0
120
     */
121
    private $symbolY = 10.5;
122
123
    /**
124
     * Text.
125
     *
126
     * @var string
127
     * @since 3.0
128
     */
129
    private $text;
130
131
    /**
132
     * Theme.
133
     *
134
     * @var array
135
     * @since 3.0
136
     */
137
    private $theme;
138
139
    /**
140
     * Vertical align.
141
     *
142
     * @var string
143
     * @since 2.0
144
     */
145
    private $verticalAlign = "top";
146
147
    /**
148
     * Width.
149
     *
150
     * @var integer
151
     * @since 2.0
152
     */
153
    private $width = 24;
154
155
    /**
156
     * X.
157
     *
158
     * @var integer
159
     * @since 2.0
160
     */
161
    private $x = -10;
162
163
    /**
164
     * Y.
165
     *
166
     * @var integer
167
     * @since 2.0
168
     */
169
    private $y = 0;
170
171
    /**
172
     * Constructor.
173
     *
174
     * @param boolean $ignoreDefaultValues Ignore the default values.
175
     */
176
    public function __construct($ignoreDefaultValues = true) {
177
        if (true === $ignoreDefaultValues) {
178
            $this->clear();
179
        }
180
    }
181
182
    /**
183
     * Clear.
184
     *
185
     * @return void
186
     */
187
    public function clear() {
188
189
        // Clear the align.
190
        $this->align = null;
191
192
        // Clear the enabled.
193
        $this->enabled = null;
194
195
        // Clear the height.
196
        $this->height = null;
197
198
        // Clear the menu items.
199
        $this->menuItems = 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 $menuItems.

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...
200
201
        // Clear the onclick.
202
        $this->onclick = null;
203
204
        // Clear the symbol.
205
        $this->symbol = null;
206
207
        // Clear the symbol fill.
208
        $this->symbolFill = null;
209
210
        // Clear the symbol size.
211
        $this->symbolSize = null;
212
213
        // Clear the symbol stroke.
214
        $this->symbolStroke = null;
215
216
        // Clear the symbol stroke width.
217
        $this->symbolStrokeWidth = null;
218
219
        // Clear the symbol x.
220
        $this->symbolX = null;
221
222
        // Clear the symbol y.
223
        $this->symbolY = null;
224
225
        // Clear the text.
226
        $this->text = null;
227
228
        // Clear the theme.
229
        $this->theme = 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 $theme.

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...
230
231
        // Clear the vertical align.
232
        $this->verticalAlign = null;
233
234
        // Clear the width.
235
        $this->width = null;
236
237
        // Clear the x.
238
        $this->x = null;
239
240
        // Clear the y.
241
        $this->y = null;
242
    }
243
244
    /**
245
     * Get the align.
246
     *
247
     * @return string Returns the align.
248
     */
249
    public function getAlign() {
250
        return $this->align;
251
    }
252
253
    /**
254
     * Get the enabled.
255
     *
256
     * @return boolean Returns the enabled.
257
     */
258
    public function getEnabled() {
259
        return $this->enabled;
260
    }
261
262
    /**
263
     * Get the height.
264
     *
265
     * @return integer Returns the height.
266
     */
267
    public function getHeight() {
268
        return $this->height;
269
    }
270
271
    /**
272
     * Get the menu items.
273
     *
274
     * @return array Returns the menu items.
275
     */
276
    public function getMenuItems() {
277
        return $this->menuItems;
278
    }
279
280
    /**
281
     * Get the onclick.
282
     *
283
     * @return string Returns the onclick.
284
     */
285
    public function getOnclick() {
286
        return $this->onclick;
287
    }
288
289
    /**
290
     * Get the symbol.
291
     *
292
     * @return string Returns the symbol.
293
     */
294
    public function getSymbol() {
295
        return $this->symbol;
296
    }
297
298
    /**
299
     * Get the symbol fill.
300
     *
301
     * @return string Returns the symbol fill.
302
     */
303
    public function getSymbolFill() {
304
        return $this->symbolFill;
305
    }
306
307
    /**
308
     * Get the symbol size.
309
     *
310
     * @return integer Returns the symbol size.
311
     */
312
    public function getSymbolSize() {
313
        return $this->symbolSize;
314
    }
315
316
    /**
317
     * Get the symbol stroke.
318
     *
319
     * @return string Returns the symbol stroke.
320
     */
321
    public function getSymbolStroke() {
322
        return $this->symbolStroke;
323
    }
324
325
    /**
326
     * Get the symbol stroke width.
327
     *
328
     * @return integer Returns the symbol stroke width.
329
     */
330
    public function getSymbolStrokeWidth() {
331
        return $this->symbolStrokeWidth;
332
    }
333
334
    /**
335
     * Get the symbol x.
336
     *
337
     * @return integer Returns the symbol x.
338
     */
339
    public function getSymbolX() {
340
        return $this->symbolX;
341
    }
342
343
    /**
344
     * Get the symbol y.
345
     *
346
     * @return integer Returns the symbol y.
347
     */
348
    public function getSymbolY() {
349
        return $this->symbolY;
350
    }
351
352
    /**
353
     * Get the text.
354
     *
355
     * @return string Returns the text.
356
     */
357
    public function getText() {
358
        return $this->text;
359
    }
360
361
    /**
362
     * Get the theme.
363
     *
364
     * @return array Returns the theme.
365
     */
366
    public function getTheme() {
367
        return $this->theme;
368
    }
369
370
    /**
371
     * Get the vertical align.
372
     *
373
     * @return string Returns the vertical align.
374
     */
375
    public function getVerticalAlign() {
376
        return $this->verticalAlign;
377
    }
378
379
    /**
380
     * Get the width.
381
     *
382
     * @return integer Returns the width.
383
     */
384
    public function getWidth() {
385
        return $this->width;
386
    }
387
388
    /**
389
     * Get the x.
390
     *
391
     * @return integer Returns the x.
392
     */
393
    public function getX() {
394
        return $this->x;
395
    }
396
397
    /**
398
     * Get the y.
399
     *
400
     * @return integer Returns the y.
401
     */
402
    public function getY() {
403
        return $this->y;
404
    }
405
406
    /**
407
     * Serialize this instance.
408
     *
409
     * @return array Returns an array representing this instance.
410
     */
411
    public function jsonSerialize() {
412
        return $this->toArray();
413
    }
414
415
    /**
416
     * Set the align.
417
     *
418
     * @param string $align The align.
419
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\Exporting\Buttons\HighchartsContextButton Returns the highcharts context button.
420
     */
421
    public function setAlign($align) {
422
        switch ($align) {
423
            case "center":
424
            case "left":
425
            case "right":
426
            $this->align = $align;
427
            break;
428
        }
429
        return $this;
430
    }
431
432
    /**
433
     * Set the enabled.
434
     *
435
     * @param boolean $enabled The enabled.
436
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\Exporting\Buttons\HighchartsContextButton Returns the highcharts context button.
437
     */
438
    public function setEnabled($enabled) {
439
        $this->enabled = $enabled;
440
        return $this;
441
    }
442
443
    /**
444
     * Set the height.
445
     *
446
     * @param integer $height The height.
447
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\Exporting\Buttons\HighchartsContextButton Returns the highcharts context button.
448
     */
449
    public function setHeight($height) {
450
        $this->height = $height;
451
        return $this;
452
    }
453
454
    /**
455
     * Set the menu items.
456
     *
457
     * @param array $menuItems The menu items.
458
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\Exporting\Buttons\HighchartsContextButton Returns the highcharts context button.
459
     */
460
    public function setMenuItems(array $menuItems = null) {
461
        $this->menuItems = $menuItems;
0 ignored issues
show
Documentation Bug introduced by
It seems like $menuItems can be null. However, the property $menuItems 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...
462
        return $this;
463
    }
464
465
    /**
466
     * Set the onclick.
467
     *
468
     * @param string $onclick The onclick.
469
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\Exporting\Buttons\HighchartsContextButton Returns the highcharts context button.
470
     */
471
    public function setOnclick($onclick) {
472
        $this->onclick = $onclick;
473
        return $this;
474
    }
475
476
    /**
477
     * Set the symbol.
478
     *
479
     * @param string $symbol The symbol.
480
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\Exporting\Buttons\HighchartsContextButton Returns the highcharts context button.
481
     */
482
    public function setSymbol($symbol) {
483
        switch ($symbol) {
484
            case "circle":
485
            case "diamond":
486
            case "menu":
487
            case "square":
488
            case "triangle":
489
            case "triangle-down":
490
            $this->symbol = $symbol;
491
            break;
492
        }
493
        return $this;
494
    }
495
496
    /**
497
     * Set the symbol fill.
498
     *
499
     * @param string $symbolFill The symbol fill.
500
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\Exporting\Buttons\HighchartsContextButton Returns the highcharts context button.
501
     */
502
    public function setSymbolFill($symbolFill) {
503
        $this->symbolFill = $symbolFill;
504
        return $this;
505
    }
506
507
    /**
508
     * Set the symbol size.
509
     *
510
     * @param integer $symbolSize The symbol size.
511
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\Exporting\Buttons\HighchartsContextButton Returns the highcharts context button.
512
     */
513
    public function setSymbolSize($symbolSize) {
514
        $this->symbolSize = $symbolSize;
515
        return $this;
516
    }
517
518
    /**
519
     * Set the symbol stroke.
520
     *
521
     * @param string $symbolStroke The symbol stroke.
522
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\Exporting\Buttons\HighchartsContextButton Returns the highcharts context button.
523
     */
524
    public function setSymbolStroke($symbolStroke) {
525
        $this->symbolStroke = $symbolStroke;
526
        return $this;
527
    }
528
529
    /**
530
     * Set the symbol stroke width.
531
     *
532
     * @param integer $symbolStrokeWidth The symbol stroke width.
533
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\Exporting\Buttons\HighchartsContextButton Returns the highcharts context button.
534
     */
535
    public function setSymbolStrokeWidth($symbolStrokeWidth) {
536
        $this->symbolStrokeWidth = $symbolStrokeWidth;
537
        return $this;
538
    }
539
540
    /**
541
     * Set the symbol x.
542
     *
543
     * @param integer $symbolX The symbol x.
544
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\Exporting\Buttons\HighchartsContextButton Returns the highcharts context button.
545
     */
546
    public function setSymbolX($symbolX) {
547
        $this->symbolX = $symbolX;
548
        return $this;
549
    }
550
551
    /**
552
     * Set the symbol y.
553
     *
554
     * @param integer $symbolY The symbol y.
555
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\Exporting\Buttons\HighchartsContextButton Returns the highcharts context button.
556
     */
557
    public function setSymbolY($symbolY) {
558
        $this->symbolY = $symbolY;
559
        return $this;
560
    }
561
562
    /**
563
     * Set the text.
564
     *
565
     * @param string $text The text.
566
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\Exporting\Buttons\HighchartsContextButton Returns the highcharts context button.
567
     */
568
    public function setText($text) {
569
        $this->text = $text;
570
        return $this;
571
    }
572
573
    /**
574
     * Set the theme.
575
     *
576
     * @param array $theme The theme.
577
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\Exporting\Buttons\HighchartsContextButton Returns the highcharts context button.
578
     */
579
    public function setTheme(array $theme = null) {
580
        $this->theme = $theme;
0 ignored issues
show
Documentation Bug introduced by
It seems like $theme can be null. However, the property $theme 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...
581
        return $this;
582
    }
583
584
    /**
585
     * Set the vertical align.
586
     *
587
     * @param string $verticalAlign The vertical align.
588
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\Exporting\Buttons\HighchartsContextButton Returns the highcharts context button.
589
     */
590
    public function setVerticalAlign($verticalAlign) {
591
        switch ($verticalAlign) {
592
            case "bottom":
593
            case "middle":
594
            case "top":
595
            $this->verticalAlign = $verticalAlign;
596
            break;
597
        }
598
        return $this;
599
    }
600
601
    /**
602
     * Set the width.
603
     *
604
     * @param integer $width The width.
605
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\Exporting\Buttons\HighchartsContextButton Returns the highcharts context button.
606
     */
607
    public function setWidth($width) {
608
        $this->width = $width;
609
        return $this;
610
    }
611
612
    /**
613
     * Set the x.
614
     *
615
     * @param integer $x The x.
616
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\Exporting\Buttons\HighchartsContextButton Returns the highcharts context button.
617
     */
618
    public function setX($x) {
619
        $this->x = $x;
620
        return $this;
621
    }
622
623
    /**
624
     * Set the y.
625
     *
626
     * @param integer $y The y.
627
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\Exporting\Buttons\HighchartsContextButton Returns the highcharts context button.
628
     */
629
    public function setY($y) {
630
        $this->y = $y;
631
        return $this;
632
    }
633
634
    /**
635
     * Convert into an array representing this instance.
636
     *
637
     * @return array Returns an array representing this instance.
638
     */
639
    public function toArray() {
640
641
        // Initialize the output.
642
        $output = [];
643
644
        // Set the align.
645
        ArrayUtility::set($output, "align", $this->align, [null]);
646
647
        // Set the enabled.
648
        ArrayUtility::set($output, "enabled", $this->enabled, [null]);
649
650
        // Set the height.
651
        ArrayUtility::set($output, "height", $this->height, [null]);
652
653
        // Set the menu items.
654
        ArrayUtility::set($output, "menuItems", $this->menuItems, [null]);
655
656
        // Set the onclick.
657
        ArrayUtility::set($output, "onclick", $this->onclick, [null]);
658
659
        // Set the symbol.
660
        ArrayUtility::set($output, "symbol", $this->symbol, [null]);
661
662
        // Set the symbol fill.
663
        ArrayUtility::set($output, "symbolFill", $this->symbolFill, [null]);
664
665
        // Set the symbol size.
666
        ArrayUtility::set($output, "symbolSize", $this->symbolSize, [null]);
667
668
        // Set the symbol stroke.
669
        ArrayUtility::set($output, "symbolStroke", $this->symbolStroke, [null]);
670
671
        // Set the symbol stroke width.
672
        ArrayUtility::set($output, "symbolStrokeWidth", $this->symbolStrokeWidth, [null]);
673
674
        // Set the symbol x.
675
        ArrayUtility::set($output, "symbolX", $this->symbolX, [null]);
676
677
        // Set the symbol y.
678
        ArrayUtility::set($output, "symbolY", $this->symbolY, [null]);
679
680
        // Set the text.
681
        ArrayUtility::set($output, "text", $this->text, [null]);
682
683
        // Set the theme.
684
        ArrayUtility::set($output, "theme", $this->theme, [null]);
685
686
        // Set the vertical align.
687
        ArrayUtility::set($output, "verticalAlign", $this->verticalAlign, [null]);
688
689
        // Set the width.
690
        ArrayUtility::set($output, "width", $this->width, [null]);
691
692
        // Set the x.
693
        ArrayUtility::set($output, "x", $this->x, [null]);
694
695
        // Set the y.
696
        ArrayUtility::set($output, "y", $this->y, [null]);
697
698
        // Return the output.
699
        return $output;
700
    }
701
702
}
703