ControlMediaCommand   A
last analyzed

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 jsonSerialize() 0 17 4
A __construct() 0 6 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\ControlMediaCommand as ControlMediaCommandType;
8
9
class ControlMediaCommand extends AbstractStandardCommand
10
{
11
    public const TYPE = 'ControlMedia';
12
13
    /**
14
     * @param ControlMediaCommandType|null $command The media control command to execute
15
     * @param string|null $componentId The ID of the component to control
16
     * @param int|null $value Integer value for commands that require it
17
     */
18 5
    public function __construct(
19
        public ?ControlMediaCommandType $command = null,
20
        public ?string $componentId = null,
21
        public ?int $value = null,
22
    ) {
23 5
        parent::__construct(self::TYPE);
24
    }
25
26 3
    public function jsonSerialize(): array
27
    {
28 3
        $data = parent::jsonSerialize();
29
30 3
        if ($this->command !== null) {
31 2
            $data['command'] = $this->command->value;
32
        }
33
34 3
        if ($this->componentId !== null) {
35 2
            $data['componentId'] = $this->componentId;
36
        }
37
38 3
        if ($this->value !== null) {
39 1
            $data['value'] = $this->value;
40
        }
41
42 3
        return $data;
43
    }
44
}
45