HighchartsDrillUpButton   A
last analyzed

Complexity

Total Complexity 11

Size/Duplication

Total Lines 147
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 11
lcom 1
cbo 1
dl 0
loc 147
rs 10
c 0
b 0
f 0

10 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 2
A clear() 0 11 1
A getPosition() 0 3 1
A getRelativeTo() 0 3 1
A getTheme() 0 3 1
A jsonSerialize() 0 3 1
A setPosition() 0 4 1
A setRelativeTo() 0 4 1
A setTheme() 0 4 1
A toArray() 0 17 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\Drilldown;
13
14
use JsonSerializable;
15
use WBW\Library\Core\Utility\Argument\ArrayUtility;
16
17
/**
18
 * Highcharts drill up button.
19
 *
20
 * @author webeweb <https://github.com/webeweb/>
21
 * @package WBW\Bundle\HighchartsBundle\API\Chart\Drilldown
22
 * @version 5.0.14
23
 * @final
24
 */
25
final class HighchartsDrillUpButton implements JsonSerializable {
26
27
    /**
28
     * Position.
29
     *
30
     * @var array
31
     * @since 3.0.8
32
     */
33
    private $position;
34
35
    /**
36
     * Relative to.
37
     *
38
     * @var string
39
     * @since 3.0.8
40
     */
41
    private $relativeTo = "plotBox";
42
43
    /**
44
     * Theme.
45
     *
46
     * @var array
47
     * @since 3.0.8
48
     */
49
    private $theme;
50
51
    /**
52
     * Constructor.
53
     *
54
     * @param boolean $ignoreDefaultValues Ignore the default values.
55
     */
56
    public function __construct($ignoreDefaultValues = true) {
57
        if (true === $ignoreDefaultValues) {
58
            $this->clear();
59
        }
60
    }
61
62
    /**
63
     * Clear.
64
     *
65
     * @return void
66
     */
67
    public function clear() {
68
69
        // Clear the position.
70
        $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...
71
72
        // Clear the relative to.
73
        $this->relativeTo = null;
74
75
        // Clear the theme.
76
        $this->theme = 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 $theme.

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...
77
    }
78
79
    /**
80
     * Get the position.
81
     *
82
     * @return array Returns the position.
83
     */
84
    public function getPosition() {
85
        return $this->position;
86
    }
87
88
    /**
89
     * Get the relative to.
90
     *
91
     * @return string Returns the relative to.
92
     */
93
    public function getRelativeTo() {
94
        return $this->relativeTo;
95
    }
96
97
    /**
98
     * Get the theme.
99
     *
100
     * @return array Returns the theme.
101
     */
102
    public function getTheme() {
103
        return $this->theme;
104
    }
105
106
    /**
107
     * Serialize this instance.
108
     *
109
     * @return array Returns an array representing this instance.
110
     */
111
    public function jsonSerialize() {
112
        return $this->toArray();
113
    }
114
115
    /**
116
     * Set the position.
117
     *
118
     * @param array $position The position.
119
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\Drilldown\HighchartsDrillUpButton Returns the highcharts drill up button.
120
     */
121
    public function setPosition(array $position = null) {
122
        $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...
123
        return $this;
124
    }
125
126
    /**
127
     * Set the relative to.
128
     *
129
     * @param string $relativeTo The relative to.
130
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\Drilldown\HighchartsDrillUpButton Returns the highcharts drill up button.
131
     */
132
    public function setRelativeTo($relativeTo) {
133
        $this->relativeTo = $relativeTo;
134
        return $this;
135
    }
136
137
    /**
138
     * Set the theme.
139
     *
140
     * @param array $theme The theme.
141
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\Drilldown\HighchartsDrillUpButton Returns the highcharts drill up button.
142
     */
143
    public function setTheme(array $theme = null) {
144
        $this->theme = $theme;
0 ignored issues
show
Documentation Bug introduced by
It seems like $theme can be null. However, the property $theme 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...
145
        return $this;
146
    }
147
148
    /**
149
     * Convert into an array representing this instance.
150
     *
151
     * @return array Returns an array representing this instance.
152
     */
153
    public function toArray() {
154
155
        // Initialize the output.
156
        $output = [];
157
158
        // Set the position.
159
        ArrayUtility::set($output, "position", $this->position, [null]);
160
161
        // Set the relative to.
162
        ArrayUtility::set($output, "relativeTo", $this->relativeTo, [null]);
163
164
        // Set the theme.
165
        ArrayUtility::set($output, "theme", $this->theme, [null]);
166
167
        // Return the output.
168
        return $output;
169
    }
170
171
}
172