HighchartsTitle   A
last analyzed

Complexity

Total Complexity 28

Size/Duplication

Total Lines 387
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 28
lcom 1
cbo 1
dl 0
loc 387
rs 10
c 0
b 0
f 0

24 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 2
A clear() 0 32 1
A getAlign() 0 3 1
A getEnabled() 0 3 1
A getMargin() 0 3 1
A getOffset() 0 3 1
A getReserveSpace() 0 3 1
A getRotation() 0 3 1
A getStyle() 0 3 1
A getText() 0 3 1
A getX() 0 3 1
A getY() 0 3 1
A jsonSerialize() 0 3 1
A setAlign() 0 10 4
A setEnabled() 0 4 1
A setMargin() 0 4 1
A setOffset() 0 4 1
A setReserveSpace() 0 4 1
A setRotation() 0 4 1
A setStyle() 0 4 1
A setText() 0 4 1
A setX() 0 4 1
A setY() 0 4 1
A toArray() 0 38 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\ZAxis;
13
14
use JsonSerializable;
15
use WBW\Library\Core\Utility\Argument\ArrayUtility;
16
17
/**
18
 * Highcharts title.
19
 *
20
 * @author webeweb <https://github.com/webeweb/>
21
 * @package WBW\Bundle\HighchartsBundle\API\Chart\ZAxis
22
 * @version 5.0.14
23
 * @final
24
 */
25
final class HighchartsTitle implements JsonSerializable {
26
27
    /**
28
     * Align.
29
     *
30
     * @var string
31
     */
32
    private $align = "middle";
33
34
    /**
35
     * Enabled.
36
     *
37
     * @var string
38
     * @deprecated
39
     */
40
    private $enabled = "middle";
41
42
    /**
43
     * Margin.
44
     *
45
     * @var integer
46
     */
47
    private $margin;
48
49
    /**
50
     * Offset.
51
     *
52
     * @var integer
53
     * @since 2.2.0
54
     */
55
    private $offset;
56
57
    /**
58
     * Reserve space.
59
     *
60
     * @var boolean
61
     * @since 5.0.11
62
     */
63
    private $reserveSpace = true;
64
65
    /**
66
     * Rotation.
67
     *
68
     * @var integer
69
     */
70
    private $rotation = 0;
71
72
    /**
73
     * Style.
74
     *
75
     * @var array
76
     */
77
    private $style = ["color" => "#666666"];
78
79
    /**
80
     * Text.
81
     *
82
     * @var string
83
     */
84
    private $text;
85
86
    /**
87
     * X.
88
     *
89
     * @var integer
90
     * @since 4.1.6
91
     */
92
    private $x = 0;
93
94
    /**
95
     * Y.
96
     *
97
     * @var integer
98
     */
99
    private $y;
100
101
    /**
102
     * Constructor.
103
     *
104
     * @param boolean $ignoreDefaultValues Ignore the default values.
105
     */
106
    public function __construct($ignoreDefaultValues = true) {
107
        if (true === $ignoreDefaultValues) {
108
            $this->clear();
109
        }
110
    }
111
112
    /**
113
     * Clear.
114
     *
115
     * @return void
116
     */
117
    public function clear() {
118
119
        // Clear the align.
120
        $this->align = null;
121
122
        // Clear the enabled.
123
        $this->enabled = null;
0 ignored issues
show
Deprecated Code introduced by
The property WBW\Bundle\HighchartsBun...ghchartsTitle::$enabled 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...
124
125
        // Clear the margin.
126
        $this->margin = null;
127
128
        // Clear the offset.
129
        $this->offset = null;
130
131
        // Clear the reserve space.
132
        $this->reserveSpace = null;
133
134
        // Clear the rotation.
135
        $this->rotation = null;
136
137
        // Clear the style.
138
        $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...
139
140
        // Clear the text.
141
        $this->text = null;
142
143
        // Clear the x.
144
        $this->x = null;
145
146
        // Clear the y.
147
        $this->y = null;
148
    }
149
150
    /**
151
     * Get the align.
152
     *
153
     * @return string Returns the align.
154
     */
155
    public function getAlign() {
156
        return $this->align;
157
    }
158
159
    /**
160
     * Get the enabled.
161
     *
162
     * @return string Returns the enabled.
163
     * @deprecated
164
     */
165
    public function getEnabled() {
166
        return $this->enabled;
0 ignored issues
show
Deprecated Code introduced by
The property WBW\Bundle\HighchartsBun...ghchartsTitle::$enabled 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...
167
    }
168
169
    /**
170
     * Get the margin.
171
     *
172
     * @return integer Returns the margin.
173
     */
174
    public function getMargin() {
175
        return $this->margin;
176
    }
177
178
    /**
179
     * Get the offset.
180
     *
181
     * @return integer Returns the offset.
182
     */
183
    public function getOffset() {
184
        return $this->offset;
185
    }
186
187
    /**
188
     * Get the reserve space.
189
     *
190
     * @return boolean Returns the reserve space.
191
     */
192
    public function getReserveSpace() {
193
        return $this->reserveSpace;
194
    }
195
196
    /**
197
     * Get the rotation.
198
     *
199
     * @return integer Returns the rotation.
200
     */
201
    public function getRotation() {
202
        return $this->rotation;
203
    }
204
205
    /**
206
     * Get the style.
207
     *
208
     * @return array Returns the style.
209
     */
210
    public function getStyle() {
211
        return $this->style;
212
    }
213
214
    /**
215
     * Get the text.
216
     *
217
     * @return string Returns the text.
218
     */
219
    public function getText() {
220
        return $this->text;
221
    }
222
223
    /**
224
     * Get the x.
225
     *
226
     * @return integer Returns the x.
227
     */
228
    public function getX() {
229
        return $this->x;
230
    }
231
232
    /**
233
     * Get the y.
234
     *
235
     * @return integer Returns the y.
236
     */
237
    public function getY() {
238
        return $this->y;
239
    }
240
241
    /**
242
     * Serialize this instance.
243
     *
244
     * @return array Returns an array representing this instance.
245
     */
246
    public function jsonSerialize() {
247
        return $this->toArray();
248
    }
249
250
    /**
251
     * Set the align.
252
     *
253
     * @param string $align The align.
254
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\ZAxis\HighchartsTitle Returns the highcharts title.
255
     */
256
    public function setAlign($align) {
257
        switch ($align) {
258
            case "high":
259
            case "low":
260
            case "middle":
261
            $this->align = $align;
262
            break;
263
        }
264
        return $this;
265
    }
266
267
    /**
268
     * Set the enabled.
269
     *
270
     * @param string $enabled The enabled.
271
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\ZAxis\HighchartsTitle Returns the highcharts title.
272
     * @deprecated
273
     */
274
    public function setEnabled($enabled) {
275
        $this->enabled = $enabled;
0 ignored issues
show
Deprecated Code introduced by
The property WBW\Bundle\HighchartsBun...ghchartsTitle::$enabled 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...
276
        return $this;
277
    }
278
279
    /**
280
     * Set the margin.
281
     *
282
     * @param integer $margin The margin.
283
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\ZAxis\HighchartsTitle Returns the highcharts title.
284
     */
285
    public function setMargin($margin) {
286
        $this->margin = $margin;
287
        return $this;
288
    }
289
290
    /**
291
     * Set the offset.
292
     *
293
     * @param integer $offset The offset.
294
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\ZAxis\HighchartsTitle Returns the highcharts title.
295
     */
296
    public function setOffset($offset) {
297
        $this->offset = $offset;
298
        return $this;
299
    }
300
301
    /**
302
     * Set the reserve space.
303
     *
304
     * @param boolean $reserveSpace The reserve space.
305
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\ZAxis\HighchartsTitle Returns the highcharts title.
306
     */
307
    public function setReserveSpace($reserveSpace) {
308
        $this->reserveSpace = $reserveSpace;
309
        return $this;
310
    }
311
312
    /**
313
     * Set the rotation.
314
     *
315
     * @param integer $rotation The rotation.
316
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\ZAxis\HighchartsTitle Returns the highcharts title.
317
     */
318
    public function setRotation($rotation) {
319
        $this->rotation = $rotation;
320
        return $this;
321
    }
322
323
    /**
324
     * Set the style.
325
     *
326
     * @param array $style The style.
327
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\ZAxis\HighchartsTitle Returns the highcharts title.
328
     */
329
    public function setStyle(array $style = null) {
330
        $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...
331
        return $this;
332
    }
333
334
    /**
335
     * Set the text.
336
     *
337
     * @param string $text The text.
338
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\ZAxis\HighchartsTitle Returns the highcharts title.
339
     */
340
    public function setText($text) {
341
        $this->text = $text;
342
        return $this;
343
    }
344
345
    /**
346
     * Set the x.
347
     *
348
     * @param integer $x The x.
349
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\ZAxis\HighchartsTitle Returns the highcharts title.
350
     */
351
    public function setX($x) {
352
        $this->x = $x;
353
        return $this;
354
    }
355
356
    /**
357
     * Set the y.
358
     *
359
     * @param integer $y The y.
360
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\ZAxis\HighchartsTitle Returns the highcharts title.
361
     */
362
    public function setY($y) {
363
        $this->y = $y;
364
        return $this;
365
    }
366
367
    /**
368
     * Convert into an array representing this instance.
369
     *
370
     * @return array Returns an array representing this instance.
371
     */
372
    public function toArray() {
373
374
        // Initialize the output.
375
        $output = [];
376
377
        // Set the align.
378
        ArrayUtility::set($output, "align", $this->align, [null]);
379
380
        // Set the enabled.
381
        ArrayUtility::set($output, "enabled", $this->enabled, [null]);
0 ignored issues
show
Deprecated Code introduced by
The property WBW\Bundle\HighchartsBun...ghchartsTitle::$enabled 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...
382
383
        // Set the margin.
384
        ArrayUtility::set($output, "margin", $this->margin, [null]);
385
386
        // Set the offset.
387
        ArrayUtility::set($output, "offset", $this->offset, [null]);
388
389
        // Set the reserve space.
390
        ArrayUtility::set($output, "reserveSpace", $this->reserveSpace, [null]);
391
392
        // Set the rotation.
393
        ArrayUtility::set($output, "rotation", $this->rotation, [null]);
394
395
        // Set the style.
396
        ArrayUtility::set($output, "style", $this->style, [null]);
397
398
        // Set the text.
399
        ArrayUtility::set($output, "text", $this->text, [null]);
400
401
        // Set the x.
402
        ArrayUtility::set($output, "x", $this->x, [null]);
403
404
        // Set the y.
405
        ArrayUtility::set($output, "y", $this->y, [null]);
406
407
        // Return the output.
408
        return $output;
409
    }
410
411
}
412