SequentialCommand   A
last analyzed

Complexity

Total Complexity 11

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
B jsonSerialize() 0 25 10
A __construct() 0 8 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace MaxBeckers\AmazonAlexa\Response\Directives\APL\StandardCommand;
6
7
class SequentialCommand extends AbstractStandardCommand implements \JsonSerializable
8
{
9
    public const TYPE = 'Sequential';
10
11
    /**
12
     * @param AbstractStandardCommand[]|null $catch Commands to run if an error occurs
13
     * @param AbstractStandardCommand[]|null $commands Commands to run sequentially
14
     * @param array|null $data Array of data to iterate over
15
     * @param int|null $repeatCount Number of times to repeat the sequence
16
     * @param AbstractStandardCommand[]|null $finally Commands to run after completion
17
     */
18 7
    public function __construct(
19
        public ?array $catch = null,
20
        public ?array $commands = null,
21
        public ?array $data = null,
22
        public ?int $repeatCount = null,
23
        public ?array $finally = null,
24
    ) {
25 7
        parent::__construct(self::TYPE);
26
    }
27
28 5
    public function jsonSerialize(): array
29
    {
30 5
        $data = parent::jsonSerialize();
31
32 5
        if ($this->catch !== null && !empty($this->catch)) {
33 1
            $data['catch'] = $this->catch;
34
        }
35
36 5
        if ($this->commands !== null && !empty($this->commands)) {
37 2
            $data['commands'] = $this->commands;
38
        }
39
40 5
        if ($this->data !== null && !empty($this->data)) {
41 1
            $data['data'] = $this->data;
42
        }
43
44 5
        if ($this->repeatCount !== null) {
45 3
            $data['repeatCount'] = $this->repeatCount;
46
        }
47
48 5
        if ($this->finally !== null && !empty($this->finally)) {
49 1
            $data['finally'] = $this->finally;
50
        }
51
52 5
        return $data;
53
    }
54
}
55