HighchartsNoData::setPosition()   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 no data.
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 HighchartsNoData implements JsonSerializable {
26
27
    /**
28
     * Attr.
29
     *
30
     * @var array
31
     * @since 3.0.8
32
     */
33
    private $attr;
34
35
    /**
36
     * Position.
37
     *
38
     * @var array
39
     * @since 3.0.8
40
     */
41
    private $position = ["x" => 0, "y" => 0, "align" => "center", "verticalAlign" => "middle"];
42
43
    /**
44
     * Style.
45
     *
46
     * @var array
47
     * @since 3.0.8
48
     */
49
    private $style = ["fontSize" => "12px", "fontWeight" => "bold", "color" => "#666666"];
50
51
    /**
52
     * Use HTML.
53
     *
54
     * @var boolean
55
     * @since 4.1.10
56
     */
57
    private $useHTML = false;
58
59
    /**
60
     * Constructor.
61
     *
62
     * @param boolean $ignoreDefaultValues Ignore the default values.
63
     */
64
    public function __construct($ignoreDefaultValues = true) {
65
        if (true === $ignoreDefaultValues) {
66
            $this->clear();
67
        }
68
    }
69
70
    /**
71
     * Clear.
72
     *
73
     * @return void
74
     */
75
    public function clear() {
76
77
        // Clear the attr.
78
        $this->attr = 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 $attr.

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...
79
80
        // Clear the position.
81
        $this->position = 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 $position.

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...
82
83
        // Clear the style.
84
        $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...
85
86
        // Clear the use HTML.
87
        $this->useHTML = null;
88
    }
89
90
    /**
91
     * Get the attr.
92
     *
93
     * @return array Returns the attr.
94
     */
95
    public function getAttr() {
96
        return $this->attr;
97
    }
98
99
    /**
100
     * Get the position.
101
     *
102
     * @return array Returns the position.
103
     */
104
    public function getPosition() {
105
        return $this->position;
106
    }
107
108
    /**
109
     * Get the style.
110
     *
111
     * @return array Returns the style.
112
     */
113
    public function getStyle() {
114
        return $this->style;
115
    }
116
117
    /**
118
     * Get the use HTML.
119
     *
120
     * @return boolean Returns the use HTML.
121
     */
122
    public function getUseHTML() {
123
        return $this->useHTML;
124
    }
125
126
    /**
127
     * Serialize this instance.
128
     *
129
     * @return array Returns an array representing this instance.
130
     */
131
    public function jsonSerialize() {
132
        return $this->toArray();
133
    }
134
135
    /**
136
     * Set the attr.
137
     *
138
     * @param array $attr The attr.
139
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\HighchartsNoData Returns the highcharts no data.
140
     */
141
    public function setAttr(array $attr = null) {
142
        $this->attr = $attr;
0 ignored issues
show
Documentation Bug introduced by
It seems like $attr can be null. However, the property $attr 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...
143
        return $this;
144
    }
145
146
    /**
147
     * Set the position.
148
     *
149
     * @param array $position The position.
150
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\HighchartsNoData Returns the highcharts no data.
151
     */
152
    public function setPosition(array $position = null) {
153
        $this->position = $position;
0 ignored issues
show
Documentation Bug introduced by
It seems like $position can be null. However, the property $position 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...
154
        return $this;
155
    }
156
157
    /**
158
     * Set the style.
159
     *
160
     * @param array $style The style.
161
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\HighchartsNoData Returns the highcharts no data.
162
     */
163
    public function setStyle(array $style = null) {
164
        $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...
165
        return $this;
166
    }
167
168
    /**
169
     * Set the use HTML.
170
     *
171
     * @param boolean $useHTML The use HTML.
172
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\HighchartsNoData Returns the highcharts no data.
173
     */
174
    public function setUseHTML($useHTML) {
175
        $this->useHTML = $useHTML;
176
        return $this;
177
    }
178
179
    /**
180
     * Convert into an array representing this instance.
181
     *
182
     * @return array Returns an array representing this instance.
183
     */
184
    public function toArray() {
185
186
        // Initialize the output.
187
        $output = [];
188
189
        // Set the attr.
190
        ArrayUtility::set($output, "attr", $this->attr, [null]);
191
192
        // Set the position.
193
        ArrayUtility::set($output, "position", $this->position, [null]);
194
195
        // Set the style.
196
        ArrayUtility::set($output, "style", $this->style, [null]);
197
198
        // Set the use HTML.
199
        ArrayUtility::set($output, "useHTML", $this->useHTML, [null]);
200
201
        // Return the output.
202
        return $output;
203
    }
204
205
}
206