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