HighchartsGlobal::__construct()   A
last analyzed

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\Options;
13
14
use JsonSerializable;
15
use WBW\Library\Core\Utility\Argument\ArrayUtility;
16
17
/**
18
 * Highcharts global.
19
 *
20
 * @author webeweb <https://github.com/webeweb/>
21
 * @package WBW\Bundle\HighchartsBundle\API\Options
22
 * @version 5.0.14
23
 * @final
24
 */
25
final class HighchartsGlobal implements JsonSerializable {
26
27
    /**
28
     * Date.
29
     *
30
     * @var array
31
     * @since 4.0.4
32
     */
33
    private $date;
34
35
    /**
36
     * VML radial gradient URL.
37
     *
38
     * @var string
39
     * @since 2.3.0
40
     */
41
    private $vMLRadialGradientURL = "http://code.highcharts.com/{version}/gfx/vml-radial-gradient.png";
42
43
    /**
44
     * Canvas tools URL.
45
     *
46
     * @var string
47
     * @deprecated
48
     */
49
    private $canvasToolsURL = "http://code.highcharts.com/{version}/modules/canvas-tools.js";
50
51
    /**
52
     * Get timezone offset.
53
     *
54
     * @var string
55
     * @since 4.1.0
56
     */
57
    private $getTimezoneOffset;
58
59
    /**
60
     * Timezone.
61
     *
62
     * @var string
63
     * @since 5.0.7
64
     */
65
    private $timezone;
66
67
    /**
68
     * Timezone offset.
69
     *
70
     * @var integer
71
     * @since 3.0.8
72
     */
73
    private $timezoneOffset = 0;
74
75
    /**
76
     * Use UTC.
77
     *
78
     * @var boolean
79
     */
80
    private $useUTC = true;
81
82
    /**
83
     * Constructor.
84
     *
85
     * @param boolean $ignoreDefaultValues Ignore the default values.
86
     */
87
    public function __construct($ignoreDefaultValues = true) {
88
        if (true === $ignoreDefaultValues) {
89
            $this->clear();
90
        }
91
    }
92
93
    /**
94
     * Clear.
95
     *
96
     * @return void
97
     */
98
    public function clear() {
99
100
        // Clear the date.
101
        $this->date = 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 $date.

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...
102
103
        // Clear the VML radial gradient URL.
104
        $this->vMLRadialGradientURL = null;
105
106
        // Clear the canvas tools URL.
107
        $this->canvasToolsURL = null;
0 ignored issues
show
Deprecated Code introduced by
The property WBW\Bundle\HighchartsBun...Global::$canvasToolsURL 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...
108
109
        // Clear the get timezone offset.
110
        $this->getTimezoneOffset = null;
111
112
        // Clear the timezone.
113
        $this->timezone = null;
114
115
        // Clear the timezone offset.
116
        $this->timezoneOffset = null;
117
118
        // Clear the use UTC.
119
        $this->useUTC = null;
120
    }
121
122
    /**
123
     * Get the date.
124
     *
125
     * @return array Returns the date.
126
     */
127
    public function getDate() {
128
        return $this->date;
129
    }
130
131
    /**
132
     * Get the VML radial gradient URL.
133
     *
134
     * @return string Returns the VML radial gradient URL.
135
     */
136
    public function getVMLRadialGradientURL() {
137
        return $this->vMLRadialGradientURL;
138
    }
139
140
    /**
141
     * Get the canvas tools URL.
142
     *
143
     * @return string Returns the canvas tools URL.
144
     * @deprecated
145
     */
146
    public function getCanvasToolsURL() {
147
        return $this->canvasToolsURL;
0 ignored issues
show
Deprecated Code introduced by
The property WBW\Bundle\HighchartsBun...Global::$canvasToolsURL 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...
148
    }
149
150
    /**
151
     * Get the get timezone offset.
152
     *
153
     * @return string Returns the get timezone offset.
154
     */
155
    public function getGetTimezoneOffset() {
156
        return $this->getTimezoneOffset;
157
    }
158
159
    /**
160
     * Get the timezone.
161
     *
162
     * @return string Returns the timezone.
163
     */
164
    public function getTimezone() {
165
        return $this->timezone;
166
    }
167
168
    /**
169
     * Get the timezone offset.
170
     *
171
     * @return integer Returns the timezone offset.
172
     */
173
    public function getTimezoneOffset() {
174
        return $this->timezoneOffset;
175
    }
176
177
    /**
178
     * Get the use UTC.
179
     *
180
     * @return boolean Returns the use UTC.
181
     */
182
    public function getUseUTC() {
183
        return $this->useUTC;
184
    }
185
186
    /**
187
     * Serialize this instance.
188
     *
189
     * @return array Returns an array representing this instance.
190
     */
191
    public function jsonSerialize() {
192
        return $this->toArray();
193
    }
194
195
    /**
196
     * Set the date.
197
     *
198
     * @param array $date The date.
199
     * @return \WBW\Bundle\HighchartsBundle\API\Options\HighchartsGlobal Returns the highcharts global.
200
     */
201
    public function setDate(array $date = null) {
202
        $this->date = $date;
0 ignored issues
show
Documentation Bug introduced by
It seems like $date can be null. However, the property $date 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...
203
        return $this;
204
    }
205
206
    /**
207
     * Set the VML radial gradient URL.
208
     *
209
     * @param string $vMLRadialGradientURL The VML radial gradient URL.
210
     * @return \WBW\Bundle\HighchartsBundle\API\Options\HighchartsGlobal Returns the highcharts global.
211
     */
212
    public function setVMLRadialGradientURL($vMLRadialGradientURL) {
213
        $this->vMLRadialGradientURL = $vMLRadialGradientURL;
214
        return $this;
215
    }
216
217
    /**
218
     * Set the canvas tools URL.
219
     *
220
     * @param string $canvasToolsURL The canvas tools URL.
221
     * @return \WBW\Bundle\HighchartsBundle\API\Options\HighchartsGlobal Returns the highcharts global.
222
     * @deprecated
223
     */
224
    public function setCanvasToolsURL($canvasToolsURL) {
225
        $this->canvasToolsURL = $canvasToolsURL;
0 ignored issues
show
Deprecated Code introduced by
The property WBW\Bundle\HighchartsBun...Global::$canvasToolsURL 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...
226
        return $this;
227
    }
228
229
    /**
230
     * Set the get timezone offset.
231
     *
232
     * @param string $getTimezoneOffset The get timezone offset.
233
     * @return \WBW\Bundle\HighchartsBundle\API\Options\HighchartsGlobal Returns the highcharts global.
234
     */
235
    public function setGetTimezoneOffset($getTimezoneOffset) {
236
        $this->getTimezoneOffset = $getTimezoneOffset;
237
        return $this;
238
    }
239
240
    /**
241
     * Set the timezone.
242
     *
243
     * @param string $timezone The timezone.
244
     * @return \WBW\Bundle\HighchartsBundle\API\Options\HighchartsGlobal Returns the highcharts global.
245
     */
246
    public function setTimezone($timezone) {
247
        $this->timezone = $timezone;
248
        return $this;
249
    }
250
251
    /**
252
     * Set the timezone offset.
253
     *
254
     * @param integer $timezoneOffset The timezone offset.
255
     * @return \WBW\Bundle\HighchartsBundle\API\Options\HighchartsGlobal Returns the highcharts global.
256
     */
257
    public function setTimezoneOffset($timezoneOffset) {
258
        $this->timezoneOffset = $timezoneOffset;
259
        return $this;
260
    }
261
262
    /**
263
     * Set the use UTC.
264
     *
265
     * @param boolean $useUTC The use UTC.
266
     * @return \WBW\Bundle\HighchartsBundle\API\Options\HighchartsGlobal Returns the highcharts global.
267
     */
268
    public function setUseUTC($useUTC) {
269
        $this->useUTC = $useUTC;
270
        return $this;
271
    }
272
273
    /**
274
     * Convert into an array representing this instance.
275
     *
276
     * @return array Returns an array representing this instance.
277
     */
278
    public function toArray() {
279
280
        // Initialize the output.
281
        $output = [];
282
283
        // Set the date.
284
        ArrayUtility::set($output, "Date", $this->date, [null]);
285
286
        // Set the VML radial gradient URL.
287
        ArrayUtility::set($output, "VMLRadialGradientURL", $this->vMLRadialGradientURL, [null]);
288
289
        // Set the canvas tools URL.
290
        ArrayUtility::set($output, "canvasToolsURL", $this->canvasToolsURL, [null]);
0 ignored issues
show
Deprecated Code introduced by
The property WBW\Bundle\HighchartsBun...Global::$canvasToolsURL 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...
291
292
        // Set the get timezone offset.
293
        ArrayUtility::set($output, "getTimezoneOffset", $this->getTimezoneOffset, [null]);
294
295
        // Set the timezone.
296
        ArrayUtility::set($output, "timezone", $this->timezone, [null]);
297
298
        // Set the timezone offset.
299
        ArrayUtility::set($output, "timezoneOffset", $this->timezoneOffset, [null]);
300
301
        // Set the use UTC.
302
        ArrayUtility::set($output, "useUTC", $this->useUTC, [null]);
303
304
        // Return the output.
305
        return $output;
306
    }
307
308
}
309