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

SpeakItemCommand   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A jsonSerialize() 0 16 3
A __construct() 0 7 1
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\HighlightMode;
8
use MaxBeckers\AmazonAlexa\Response\Directives\APL\Document\ScrollAlign;
9
10
class SpeakItemCommand extends AbstractStandardCommand implements \JsonSerializable
11
{
12
    public const TYPE = 'SpeakItem';
13
14
    /**
15
     * @param string|null $componentId ID of the component to speak
16
     * @param ScrollAlign $align Alignment when scrolling to the item
17
     * @param HighlightMode $highlightMode How to highlight the item being spoken
18
     * @param int|null $minimumDwellTime Minimum time to dwell on each item in milliseconds
19
     */
20 8
    public function __construct(
21
        public ?string $componentId = null,
22
        public ScrollAlign $align = ScrollAlign::VISIBLE,
23
        public HighlightMode $highlightMode = HighlightMode::BLOCK,
24
        public ?int $minimumDwellTime = null,
25
    ) {
26 8
        parent::__construct(self::TYPE);
27
    }
28
29 6
    public function jsonSerialize(): array
30
    {
31 6
        $data = parent::jsonSerialize();
32
33 6
        if ($this->componentId !== null) {
34 5
            $data['componentId'] = $this->componentId;
35
        }
36
37 6
        $data['align'] = $this->align->value;
38 6
        $data['highlightMode'] = $this->highlightMode->value;
39
40 6
        if ($this->minimumDwellTime !== null) {
41 2
            $data['minimumDwellTime'] = $this->minimumDwellTime;
42
        }
43
44 6
        return $data;
45
    }
46
}
47