Passed
Pull Request — master (#97)
by Maximilian
04:02
created

SetValueCommand   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 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
class SetValueCommand extends AbstractStandardCommand implements \JsonSerializable
8
{
9
    public const TYPE = 'SetValue';
10
11
    /**
12
     * @param string|null $componentId ID of the component to set value on
13
     * @param string|null $property Property to set
14
     * @param mixed $value Value to set
15
     */
16 9
    public function __construct(
17
        public ?string $componentId = null,
18
        public ?string $property = null,
19
        public mixed $value = null,
20
    ) {
21 9
        parent::__construct(self::TYPE);
22
    }
23
24 6
    public function jsonSerialize(): array
25
    {
26 6
        $data = parent::jsonSerialize();
27
28 6
        if ($this->componentId !== null) {
29 5
            $data['componentId'] = $this->componentId;
30
        }
31
32 6
        if ($this->property !== null) {
33 5
            $data['property'] = $this->property;
34
        }
35
36 6
        if ($this->value !== null) {
37 5
            $data['value'] = $this->value;
38
        }
39
40 6
        return $data;
41
    }
42
}
43