HighchartsPane::setStartAngle()   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;
13
14
use JsonSerializable;
15
use WBW\Library\Core\Utility\Argument\ArrayUtility;
16
17
/**
18
 * Highcharts pane.
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 HighchartsPane implements JsonSerializable {
26
27
    /**
28
     * Background.
29
     *
30
     * @var array
31
     * @since 2.3.0
32
     */
33
    private $background;
34
35
    /**
36
     * Center.
37
     *
38
     * @var array
39
     * @since 2.3.0
40
     */
41
    private $center = ["50%", "50%"];
42
43
    /**
44
     * End angle.
45
     *
46
     * @var integer
47
     * @since 2.3.0
48
     */
49
    private $endAngle;
50
51
    /**
52
     * Size.
53
     *
54
     * @var integer|string
55
     */
56
    private $size = "85%";
57
58
    /**
59
     * Start angle.
60
     *
61
     * @var integer
62
     * @since 2.3.0
63
     */
64
    private $startAngle;
65
66
    /**
67
     * Constructor.
68
     *
69
     * @param boolean $ignoreDefaultValues Ignore the default values.
70
     */
71
    public function __construct($ignoreDefaultValues = true) {
72
        if (true === $ignoreDefaultValues) {
73
            $this->clear();
74
        }
75
    }
76
77
    /**
78
     * Clear.
79
     *
80
     * @return void
81
     */
82
    public function clear() {
83
84
        // Clear the background.
85
        $this->background = 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 $background.

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...
86
87
        // Clear the center.
88
        $this->center = 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 $center.

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...
89
90
        // Clear the end angle.
91
        $this->endAngle = null;
92
93
        // Clear the size.
94
        $this->size = null;
95
96
        // Clear the start angle.
97
        $this->startAngle = null;
98
    }
99
100
    /**
101
     * Get the background.
102
     *
103
     * @return array Returns the background.
104
     */
105
    public function getBackground() {
106
        return $this->background;
107
    }
108
109
    /**
110
     * Get the center.
111
     *
112
     * @return array Returns the center.
113
     */
114
    public function getCenter() {
115
        return $this->center;
116
    }
117
118
    /**
119
     * Get the end angle.
120
     *
121
     * @return integer Returns the end angle.
122
     */
123
    public function getEndAngle() {
124
        return $this->endAngle;
125
    }
126
127
    /**
128
     * Get the size.
129
     *
130
     * @return integer|string Returns the size.
131
     */
132
    public function getSize() {
133
        return $this->size;
134
    }
135
136
    /**
137
     * Get the start angle.
138
     *
139
     * @return integer Returns the start angle.
140
     */
141
    public function getStartAngle() {
142
        return $this->startAngle;
143
    }
144
145
    /**
146
     * Serialize this instance.
147
     *
148
     * @return array Returns an array representing this instance.
149
     */
150
    public function jsonSerialize() {
151
        return $this->toArray();
152
    }
153
154
    /**
155
     * Set the background.
156
     *
157
     * @param array $background The background.
158
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\HighchartsPane Returns the highcharts pane.
159
     */
160
    public function setBackground(array $background = null) {
161
        $this->background = $background;
0 ignored issues
show
Documentation Bug introduced by
It seems like $background can be null. However, the property $background 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...
162
        return $this;
163
    }
164
165
    /**
166
     * Set the center.
167
     *
168
     * @param array $center The center.
169
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\HighchartsPane Returns the highcharts pane.
170
     */
171
    public function setCenter(array $center = null) {
172
        $this->center = $center;
0 ignored issues
show
Documentation Bug introduced by
It seems like $center can be null. However, the property $center 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...
173
        return $this;
174
    }
175
176
    /**
177
     * Set the end angle.
178
     *
179
     * @param integer $endAngle The end angle.
180
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\HighchartsPane Returns the highcharts pane.
181
     */
182
    public function setEndAngle($endAngle) {
183
        $this->endAngle = $endAngle;
184
        return $this;
185
    }
186
187
    /**
188
     * Set the size.
189
     *
190
     * @param integer|string $size The size.
191
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\HighchartsPane Returns the highcharts pane.
192
     */
193
    public function setSize($size) {
194
        $this->size = $size;
195
        return $this;
196
    }
197
198
    /**
199
     * Set the start angle.
200
     *
201
     * @param integer $startAngle The start angle.
202
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\HighchartsPane Returns the highcharts pane.
203
     */
204
    public function setStartAngle($startAngle) {
205
        $this->startAngle = $startAngle;
206
        return $this;
207
    }
208
209
    /**
210
     * Convert into an array representing this instance.
211
     *
212
     * @return array Returns an array representing this instance.
213
     */
214
    public function toArray() {
215
216
        // Initialize the output.
217
        $output = [];
218
219
        // Set the background.
220
        ArrayUtility::set($output, "background", $this->background, [null]);
221
222
        // Set the center.
223
        ArrayUtility::set($output, "center", $this->center, [null]);
224
225
        // Set the end angle.
226
        ArrayUtility::set($output, "endAngle", $this->endAngle, [null]);
227
228
        // Set the size.
229
        ArrayUtility::set($output, "size", $this->size, [null]);
230
231
        // Set the start angle.
232
        ArrayUtility::set($output, "startAngle", $this->startAngle, [null]);
233
234
        // Return the output.
235
        return $output;
236
    }
237
238
}
239