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

ScrollCommand   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 11
dl 0
loc 34
ccs 11
cts 11
cp 1
rs 10
c 1
b 0
f 1
wmc 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A jsonSerialize() 0 17 4
1
<?php
2
3
declare(strict_types=1);
4
5
namespace MaxBeckers\AmazonAlexa\Response\Directives\APL\StandardCommand;
6
7
class ScrollCommand extends AbstractStandardCommand implements \JsonSerializable
8
{
9
    public const TYPE = 'Scroll';
10
11
    /**
12
     * @param string|null $componentId ID of the component to scroll
13
     * @param int|null $distance Distance to scroll in pixels
14
     * @param int|null $targetDuration Duration of the scroll animation in milliseconds
15
     */
16 8
    public function __construct(
17
        public ?string $componentId = null,
18
        public ?int $distance = null,
19
        public ?int $targetDuration = null,
20
    ) {
21 8
        parent::__construct(self::TYPE);
22
    }
23
24 5
    public function jsonSerialize(): array
25
    {
26 5
        $data = parent::jsonSerialize();
27
28 5
        if ($this->componentId !== null) {
29 4
            $data['componentId'] = $this->componentId;
30
        }
31
32 5
        if ($this->distance !== null) {
33 4
            $data['distance'] = $this->distance;
34
        }
35
36 5
        if ($this->targetDuration !== null) {
37 3
            $data['targetDuration'] = $this->targetDuration;
38
        }
39
40 5
        return $data;
41
    }
42
}
43