HighchartsNavigation::setArrowSize()   A
last analyzed

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\Legend;
13
14
use JsonSerializable;
15
use WBW\Library\Core\Utility\Argument\ArrayUtility;
16
17
/**
18
 * Highcharts navigation.
19
 *
20
 * @author webeweb <https://github.com/webeweb/>
21
 * @package WBW\Bundle\HighchartsBundle\API\Chart\Legend
22
 * @version 5.0.14
23
 * @final
24
 */
25
final class HighchartsNavigation implements JsonSerializable {
26
27
    /**
28
     * Active color.
29
     *
30
     * @var string
31
     * @since 2.2.4
32
     */
33
    private $activeColor = "#003399";
34
35
    /**
36
     * Animation.
37
     *
38
     * @var boolean|array
39
     * @since 2.2.4
40
     */
41
    private $animation = true;
42
43
    /**
44
     * Arrow size.
45
     *
46
     * @var integer
47
     * @since 2.2.4
48
     */
49
    private $arrowSize = 12;
50
51
    /**
52
     * Enabled.
53
     *
54
     * @var boolean
55
     * @since 4.2.4
56
     */
57
    private $enabled = true;
58
59
    /**
60
     * Inactive color.
61
     *
62
     * @var string
63
     * @since 2.2.4
64
     */
65
    private $inactiveColor = "#cccccc";
66
67
    /**
68
     * Style.
69
     *
70
     * @var array
71
     * @since 2.2.4
72
     */
73
    private $style;
74
75
    /**
76
     * Constructor.
77
     *
78
     * @param boolean $ignoreDefaultValues Ignore the default values.
79
     */
80
    public function __construct($ignoreDefaultValues = true) {
81
        if (true === $ignoreDefaultValues) {
82
            $this->clear();
83
        }
84
    }
85
86
    /**
87
     * Clear.
88
     *
89
     * @return void
90
     */
91
    public function clear() {
92
93
        // Clear the active color.
94
        $this->activeColor = null;
95
96
        // Clear the animation.
97
        $this->animation = null;
98
99
        // Clear the arrow size.
100
        $this->arrowSize = null;
101
102
        // Clear the enabled.
103
        $this->enabled = null;
104
105
        // Clear the inactive color.
106
        $this->inactiveColor = null;
107
108
        // Clear the style.
109
        $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...
110
    }
111
112
    /**
113
     * Get the active color.
114
     *
115
     * @return string Returns the active color.
116
     */
117
    public function getActiveColor() {
118
        return $this->activeColor;
119
    }
120
121
    /**
122
     * Get the animation.
123
     *
124
     * @return boolean|array Returns the animation.
125
     */
126
    public function getAnimation() {
127
        return $this->animation;
128
    }
129
130
    /**
131
     * Get the arrow size.
132
     *
133
     * @return integer Returns the arrow size.
134
     */
135
    public function getArrowSize() {
136
        return $this->arrowSize;
137
    }
138
139
    /**
140
     * Get the enabled.
141
     *
142
     * @return boolean Returns the enabled.
143
     */
144
    public function getEnabled() {
145
        return $this->enabled;
146
    }
147
148
    /**
149
     * Get the inactive color.
150
     *
151
     * @return string Returns the inactive color.
152
     */
153
    public function getInactiveColor() {
154
        return $this->inactiveColor;
155
    }
156
157
    /**
158
     * Get the style.
159
     *
160
     * @return array Returns the style.
161
     */
162
    public function getStyle() {
163
        return $this->style;
164
    }
165
166
    /**
167
     * Serialize this instance.
168
     *
169
     * @return array Returns an array representing this instance.
170
     */
171
    public function jsonSerialize() {
172
        return $this->toArray();
173
    }
174
175
    /**
176
     * Set the active color.
177
     *
178
     * @param string $activeColor The active color.
179
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\Legend\HighchartsNavigation Returns the highcharts navigation.
180
     */
181
    public function setActiveColor($activeColor) {
182
        $this->activeColor = $activeColor;
183
        return $this;
184
    }
185
186
    /**
187
     * Set the animation.
188
     *
189
     * @param boolean|array $animation The animation.
190
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\Legend\HighchartsNavigation Returns the highcharts navigation.
191
     */
192
    public function setAnimation($animation) {
193
        $this->animation = $animation;
194
        return $this;
195
    }
196
197
    /**
198
     * Set the arrow size.
199
     *
200
     * @param integer $arrowSize The arrow size.
201
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\Legend\HighchartsNavigation Returns the highcharts navigation.
202
     */
203
    public function setArrowSize($arrowSize) {
204
        $this->arrowSize = $arrowSize;
205
        return $this;
206
    }
207
208
    /**
209
     * Set the enabled.
210
     *
211
     * @param boolean $enabled The enabled.
212
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\Legend\HighchartsNavigation Returns the highcharts navigation.
213
     */
214
    public function setEnabled($enabled) {
215
        $this->enabled = $enabled;
216
        return $this;
217
    }
218
219
    /**
220
     * Set the inactive color.
221
     *
222
     * @param string $inactiveColor The inactive color.
223
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\Legend\HighchartsNavigation Returns the highcharts navigation.
224
     */
225
    public function setInactiveColor($inactiveColor) {
226
        $this->inactiveColor = $inactiveColor;
227
        return $this;
228
    }
229
230
    /**
231
     * Set the style.
232
     *
233
     * @param array $style The style.
234
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\Legend\HighchartsNavigation Returns the highcharts navigation.
235
     */
236
    public function setStyle(array $style = null) {
237
        $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...
238
        return $this;
239
    }
240
241
    /**
242
     * Convert into an array representing this instance.
243
     *
244
     * @return array Returns an array representing this instance.
245
     */
246
    public function toArray() {
247
248
        // Initialize the output.
249
        $output = [];
250
251
        // Set the active color.
252
        ArrayUtility::set($output, "activeColor", $this->activeColor, [null]);
253
254
        // Set the animation.
255
        ArrayUtility::set($output, "animation", $this->animation, [null]);
256
257
        // Set the arrow size.
258
        ArrayUtility::set($output, "arrowSize", $this->arrowSize, [null]);
259
260
        // Set the enabled.
261
        ArrayUtility::set($output, "enabled", $this->enabled, [null]);
262
263
        // Set the inactive color.
264
        ArrayUtility::set($output, "inactiveColor", $this->inactiveColor, [null]);
265
266
        // Set the style.
267
        ArrayUtility::set($output, "style", $this->style, [null]);
268
269
        // Return the output.
270
        return $output;
271
    }
272
273
}
274