AnimateItemCommand   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 17
dl 0
loc 52
ccs 17
cts 17
cp 1
rs 10
c 1
b 0
f 1
wmc 8

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 1
B jsonSerialize() 0 29 7
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\RepeatMode;
8
use MaxBeckers\AmazonAlexa\Response\Directives\APL\Document\Value;
9
10
class AnimateItemCommand extends AbstractStandardCommand
11
{
12
    public const TYPE = 'AnimateItem';
13
14
    /**
15
     * @param string|null $componentId The ID of the component to animate
16
     * @param int|null $duration Duration of the animation in milliseconds
17
     * @param string|null $easing Easing function for the animation
18
     * @param int|null $repeatCount Number of times to repeat the animation
19
     * @param RepeatMode|null $repeatMode How to repeat the animation
20
     * @param Value|null $value The property and values to animate
21
     */
22 5
    public function __construct(
23
        public ?string $componentId = null,
24
        public ?int $duration = null,
25
        public ?string $easing = null,
26
        public ?int $repeatCount = null,
27
        public ?RepeatMode $repeatMode = null,
28
        public ?Value $value = null,
29
    ) {
30 5
        parent::__construct(self::TYPE);
31
    }
32
33 3
    public function jsonSerialize(): array
34
    {
35 3
        $data = parent::jsonSerialize();
36
37 3
        if ($this->componentId !== null) {
38 2
            $data['componentId'] = $this->componentId;
39
        }
40
41 3
        if ($this->duration !== null) {
42 2
            $data['duration'] = $this->duration;
43
        }
44
45 3
        if ($this->easing !== null) {
46 1
            $data['easing'] = $this->easing;
47
        }
48
49 3
        if ($this->repeatCount !== null) {
50 1
            $data['repeatCount'] = $this->repeatCount;
51
        }
52
53 3
        if ($this->repeatMode !== null) {
54 1
            $data['repeatMode'] = $this->repeatMode->value;
55
        }
56
57 3
        if ($this->value !== null) {
58 1
            $data['value'] = $this->value;
59
        }
60
61 3
        return $data;
62
    }
63
}
64