Passed
Pull Request — master (#97)
by Maximilian
03:52
created

SpeakListCommand   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 14
dl 0
loc 44
ccs 14
cts 14
cp 1
rs 10
c 1
b 0
f 1
wmc 6

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 1
A jsonSerialize() 0 23 5
1
<?php
2
3
declare(strict_types=1);
4
5
namespace MaxBeckers\AmazonAlexa\Response\Directives\APL\StandardCommand;
6
7
use MaxBeckers\AmazonAlexa\Response\Directives\APL\Document\ScrollAlign;
8
9
class SpeakListCommand extends AbstractStandardCommand implements \JsonSerializable
10
{
11
    public const TYPE = 'SpeakList';
12
13
    /**
14
     * @param string|null $componentId ID of the component to speak
15
     * @param ScrollAlign $align Alignment when scrolling to items
16
     * @param int|null $count Number of items to speak
17
     * @param int|null $minimumDwellTime Minimum time to dwell on each item in milliseconds
18
     * @param int|null $start Starting index for speaking
19
     */
20 8
    public function __construct(
21
        public ?string $componentId = null,
22
        public ScrollAlign $align = ScrollAlign::VISIBLE,
23
        public ?int $count = null,
24
        public ?int $minimumDwellTime = null,
25
        public ?int $start = null,
26
    ) {
27 8
        parent::__construct(self::TYPE);
28
    }
29
30 6
    public function jsonSerialize(): array
31
    {
32 6
        $data = parent::jsonSerialize();
33
34 6
        if ($this->componentId !== null) {
35 5
            $data['componentId'] = $this->componentId;
36
        }
37
38 6
        $data['align'] = $this->align->value;
39
40 6
        if ($this->count !== null) {
41 3
            $data['count'] = $this->count;
42
        }
43
44 6
        if ($this->minimumDwellTime !== null) {
45 2
            $data['minimumDwellTime'] = $this->minimumDwellTime;
46
        }
47
48 6
        if ($this->start !== null) {
49 2
            $data['start'] = $this->start;
50
        }
51
52 6
        return $data;
53
    }
54
}
55