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.

Line::setBorderWidth()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

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