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; |
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 |
22
|
|
|
* @version 5.0.14 |
23
|
|
|
* @final |
24
|
|
|
*/ |
25
|
|
|
final class HighchartsLabels implements JsonSerializable { |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Items. |
29
|
|
|
* |
30
|
|
|
* @var array |
31
|
|
|
*/ |
32
|
|
|
private $items; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Style. |
36
|
|
|
* |
37
|
|
|
* @var array |
38
|
|
|
*/ |
39
|
|
|
private $style = ["color" => "#333333"]; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Constructor. |
43
|
|
|
* |
44
|
|
|
* @param boolean $ignoreDefaultValues Ignore the default values. |
45
|
|
|
*/ |
46
|
|
|
public function __construct($ignoreDefaultValues = true) { |
47
|
|
|
if (true === $ignoreDefaultValues) { |
48
|
|
|
$this->clear(); |
49
|
|
|
} |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* Clear. |
54
|
|
|
* |
55
|
|
|
* @return void |
56
|
|
|
*/ |
57
|
|
|
public function clear() { |
58
|
|
|
|
59
|
|
|
// Clear the items. |
60
|
|
|
$this->items = null; |
|
|
|
|
61
|
|
|
|
62
|
|
|
// Clear the style. |
63
|
|
|
$this->style = null; |
|
|
|
|
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* Get the items. |
68
|
|
|
* |
69
|
|
|
* @return array Returns the items. |
70
|
|
|
*/ |
71
|
|
|
public function getItems() { |
72
|
|
|
return $this->items; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* Get the style. |
77
|
|
|
* |
78
|
|
|
* @return array Returns the style. |
79
|
|
|
*/ |
80
|
|
|
public function getStyle() { |
81
|
|
|
return $this->style; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* Serialize this instance. |
86
|
|
|
* |
87
|
|
|
* @return array Returns an array representing this instance. |
88
|
|
|
*/ |
89
|
|
|
public function jsonSerialize() { |
90
|
|
|
return $this->toArray(); |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* Set the items. |
95
|
|
|
* |
96
|
|
|
* @param array $items The items. |
97
|
|
|
* @return \WBW\Bundle\HighchartsBundle\API\Chart\HighchartsLabels Returns the highcharts labels. |
98
|
|
|
*/ |
99
|
|
|
public function setItems(array $items = null) { |
100
|
|
|
$this->items = $items; |
|
|
|
|
101
|
|
|
return $this; |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* Set the style. |
106
|
|
|
* |
107
|
|
|
* @param array $style The style. |
108
|
|
|
* @return \WBW\Bundle\HighchartsBundle\API\Chart\HighchartsLabels Returns the highcharts labels. |
109
|
|
|
*/ |
110
|
|
|
public function setStyle(array $style = null) { |
111
|
|
|
$this->style = $style; |
|
|
|
|
112
|
|
|
return $this; |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* Convert into an array representing this instance. |
117
|
|
|
* |
118
|
|
|
* @return array Returns an array representing this instance. |
119
|
|
|
*/ |
120
|
|
|
public function toArray() { |
121
|
|
|
|
122
|
|
|
// Initialize the output. |
123
|
|
|
$output = []; |
124
|
|
|
|
125
|
|
|
// Set the items. |
126
|
|
|
ArrayUtility::set($output, "items", $this->items, [null]); |
127
|
|
|
|
128
|
|
|
// Set the style. |
129
|
|
|
ArrayUtility::set($output, "style", $this->style, [null]); |
130
|
|
|
|
131
|
|
|
// Return the output. |
132
|
|
|
return $output; |
133
|
|
|
} |
134
|
|
|
|
135
|
|
|
} |
136
|
|
|
|
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..