GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Pull Request — master (#59)
by
unknown
02:00
created

Line::getBorderDashOffset()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Halfpastfour\PHPChartJS\Options\Elements;
4
5
6
use Halfpastfour\PHPChartJS\ArraySerializableInterface;
7
use Halfpastfour\PHPChartJS\Delegate\ArraySerializable;
8
use Zend\Json\Json;
9
10
/**
11
 * Class Line
12
 * @package Halfpastfour\PHPChartJS\Options\Elements
13
 */
14
class Line implements ArraySerializableInterface, \JsonSerializable
15
{
16
    use ArraySerializable;
17
18
    /** https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineCap */
19
    const CAP_STYLE_BUTT = 'butt';
20
    const CAP_STYLE_ROUND = 'round';
21
    const CAP_STYLE_SQUARE = 'square';
22
23
    /** https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineJoin */
24
    const JOIN_STYLE_ROUND = 'round';
25
    const JOIN_STYLE_BEVEL = 'bevel';
26
    const JOIN_STYLE_MITER = 'miter';
27
28
    const FILL_LOCATION_ZERO = 'zero';
29
    const FILL_LOCATION_TOP = 'top';
30
    const FILL_LOCATION_BOTTOM = 'bottom';
31
    const FILL_LOCATION_TRUE = true;
32
    const FILL_LOCATION_FALSE = false;
33
34
    /**
35
     * Bézier curve tension (0 for no Bézier curves).
36
     * @default 0.4
37
     * @var float
38
     */
39
    private $tension;
40
41
    /**
42
     * Line fill color.
43
     * @default 'rgba(0,0,0,0.1)'
44
     * @var string
45
     */
46
    private $backgroundColor;
47
48
    /**
49
     * Line stroke width.
50
     * @default 3
51
     * @var int
52
     */
53
    private $borderWidth;
54
55
    /**
56
     * Line stroke color.
57
     * @default 'rgba(0,0,0,0.1)'
58
     * @var string
59
     */
60
    private $borderColor;
61
62
    /**
63
     * Line cap style.
64
     * @default self::CAP_STYLE_BUTT
65
     * @var string
66
     */
67
    private $borderCapStyle;
68
69
    /**
70
     * Line dash. See https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/setLineDash
71
     * @default []
72
     * @var int[]
73
     */
74
    private $borderDash;
75
76
    /**
77
     * Line dash offset.
78
     * @default 0
79
     * @var float
80
     */
81
    private $borderDashOffset;
82
83
    /**
84
     * Line join style.
85
     * @default self::JOIN_STYLE_MITER
86
     * @var string
87
     */
88
    private $borderJoinStyle;
89
90
    /**
91
     * true to keep Bézier control inside the chart, false for no restriction.
92
     * @default true
93
     * @var bool
94
     */
95
    private $capBezierPoints;
96
97
    /**
98
     * Fill location: 'zero', 'top', 'bottom', true (eq. 'zero') or false (no fill).
99
     * @default self::FILL_LOCATION_TRUE
100
     * @var bool|string
101
     */
102
    private $fill;
103
104
    /**
105
     * true to show the line as a stepped line (tension will be ignored).
106
     * @default false
107
     * @var bool
108
     */
109
    private $stepped;
110
111
    /**
112
     * @return float
113
     */
114
    public function getTension()
115
    {
116
        return $this->tension;
117
    }
118
119
    /**
120
     * @param float $tension
121
     * @return Line
122
     */
123
    public function setTension($tension)
124
    {
125
        $this->tension = floatval($tension);
126
        return $this;
127
    }
128
129
    /**
130
     * @return string
131
     */
132
    public function getBackgroundColor()
133
    {
134
        return $this->backgroundColor;
135
    }
136
137
    /**
138
     * @param string $backgroundColor
139
     * @return Line
140
     */
141
    public function setBackgroundColor($backgroundColor)
142
    {
143
        $this->backgroundColor = is_null($backgroundColor) ? null : strval($backgroundColor);
0 ignored issues
show
introduced by
The condition is_null($backgroundColor) is always false.
Loading history...
144
        return $this;
145
    }
146
147
    /**
148
     * @return int
149
     */
150
    public function getBorderWidth()
151
    {
152
        return $this->borderWidth;
153
    }
154
155
    /**
156
     * @param int $borderWidth
157
     * @return Line
158
     */
159
    public function setBorderWidth($borderWidth)
160
    {
161
        $this->borderWidth = intval($borderWidth);
162
        return $this;
163
    }
164
165
    /**
166
     * @return string
167
     */
168
    public function getBorderColor()
169
    {
170
        return $this->borderColor;
171
    }
172
173
    /**
174
     * @param string $borderColor
175
     * @return Line
176
     */
177
    public function setBorderColor($borderColor)
178
    {
179
        $this->borderColor = is_null($borderColor) ? null : strval($borderColor);
0 ignored issues
show
introduced by
The condition is_null($borderColor) is always false.
Loading history...
180
        return $this;
181
    }
182
183
    /**
184
     * @return string
185
     */
186
    public function getBorderCapStyle()
187
    {
188
        return $this->borderCapStyle;
189
    }
190
191
    /**
192
     * @param string $borderCapStyle
193
     * @return Line
194
     */
195
    public function setBorderCapStyle($borderCapStyle)
196
    {
197
        $this->borderCapStyle = is_null($borderCapStyle) ? null : strval($borderCapStyle);
0 ignored issues
show
introduced by
The condition is_null($borderCapStyle) is always false.
Loading history...
198
        return $this;
199
    }
200
201
    /**
202
     * @return int[]
203
     */
204
    public function getBorderDash()
205
    {
206
        return $this->borderDash;
207
    }
208
209
    /**
210
     * @param int[] $borderDash
211
     * @return Line
212
     */
213
    public function setBorderDash($borderDash)
214
    {
215
        if (is_array($borderDash)) {
0 ignored issues
show
introduced by
The condition is_array($borderDash) is always true.
Loading history...
216
            array_walk_recursive(
217
                $borderDash,
218
                function (&$value) {
219
                    $value = intval($value);
220
                }
221
            );
222
            $this->borderDash = $borderDash;
223
        }
224
        return $this;
225
    }
226
227
    /**
228
     * @return float
229
     */
230
    public function getBorderDashOffset()
231
    {
232
        return $this->borderDashOffset;
233
    }
234
235
    /**
236
     * @param float $borderDashOffset
237
     * @return Line
238
     */
239
    public function setBorderDashOffset($borderDashOffset)
240
    {
241
        $this->borderDashOffset = floatval($borderDashOffset);
242
        return $this;
243
    }
244
245
    /**
246
     * @return string
247
     */
248
    public function getBorderJoinStyle()
249
    {
250
        return $this->borderJoinStyle;
251
    }
252
253
    /**
254
     * @param string $borderJoinStyle
255
     * @return Line
256
     */
257
    public function setBorderJoinStyle($borderJoinStyle)
258
    {
259
        $this->borderJoinStyle = is_null($borderJoinStyle) ? null : strval($borderJoinStyle);
0 ignored issues
show
introduced by
The condition is_null($borderJoinStyle) is always false.
Loading history...
260
        return $this;
261
    }
262
263
    /**
264
     * @return bool
265
     */
266
    public function isCapBezierPoints()
267
    {
268
        return $this->capBezierPoints;
269
    }
270
271
    /**
272
     * @param bool $capBezierPoints
273
     * @return Line
274
     */
275
    public function setCapBezierPoints($capBezierPoints)
276
    {
277
        $this->capBezierPoints = boolval($capBezierPoints);
278
        return $this;
279
    }
280
281
    /**
282
     * @return bool|string
283
     */
284
    public function getFill()
285
    {
286
        return $this->fill;
287
    }
288
289
    /**
290
     * @param bool|string $fill
291
     * @return Line
292
     */
293
    public function setFill($fill)
294
    {
295
        $this->fill = is_null($fill) ? null : (is_bool($fill) ? $fill : strval($fill));
0 ignored issues
show
introduced by
The condition is_null($fill) is always false.
Loading history...
296
        return $this;
297
    }
298
299
    /**
300
     * @return bool
301
     */
302
    public function isStepped()
303
    {
304
        return $this->stepped;
305
    }
306
307
    /**
308
     * @param bool $stepped
309
     * @return Line
310
     */
311
    public function setStepped($stepped)
312
    {
313
        $this->stepped = boolval($stepped);
314
        return $this;
315
    }
316
317
    /**
318
     * @return string
319
     * @throws \ReflectionException
320
     * @throws \Zend_Reflection_Exception
321
     */
322
    public function jsonSerialize()
323
    {
324
        return Json::encode($this->getArrayCopy());
325
    }
326
}