Passed
Push — master ( a53d55...43aca1 )
by Maximilian
03:50
created

DropShadow::jsonSerialize()   A

Complexity

Conditions 5
Paths 16

Size

Total Lines 21
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 5

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 5
eloc 10
nc 16
nop 0
dl 0
loc 21
ccs 11
cts 11
cp 1
crap 5
rs 9.6111
c 1
b 0
f 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace MaxBeckers\AmazonAlexa\Response\Directives\APL\AVGFilter;
6
7
use MaxBeckers\AmazonAlexa\Response\Directives\APL\Document\AVGFilterType;
8
9
class DropShadow extends AVGFilter implements \JsonSerializable
10
{
11
    public const TYPE = AVGFilterType::DROP_SHADOW;
12
13
    /**
14
     * @param string|null $color Color of the drop shadow
15
     * @param int|null $horizontalOffset Horizontal offset of the shadow
16
     * @param int|null $radius Blur radius of the shadow
17
     * @param int|null $verticalOffset Vertical offset of the shadow
18
     */
19 12
    public function __construct(
20
        public ?string $color = null,
21
        public ?int $horizontalOffset = null,
22
        public ?int $radius = null,
23
        public ?int $verticalOffset = null,
24
    ) {
25 12
        parent::__construct(self::TYPE);
26
    }
27
28 8
    public function jsonSerialize(): array
29
    {
30 8
        $data = parent::jsonSerialize();
31
32 8
        if ($this->color !== null) {
33 6
            $data['color'] = $this->color;
34
        }
35
36 8
        if ($this->horizontalOffset !== null) {
37 4
            $data['horizontalOffset'] = $this->horizontalOffset;
38
        }
39
40 8
        if ($this->radius !== null) {
41 5
            $data['radius'] = $this->radius;
42
        }
43
44 8
        if ($this->verticalOffset !== null) {
45 4
            $data['verticalOffset'] = $this->verticalOffset;
46
        }
47
48 8
        return $data;
49
    }
50
}
51