ParallelCommand   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 9
dl 0
loc 28
ccs 9
cts 9
cp 1
rs 10
c 1
b 0
f 1
wmc 6

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A jsonSerialize() 0 13 5
1
<?php
2
3
declare(strict_types=1);
4
5
namespace MaxBeckers\AmazonAlexa\Response\Directives\APL\StandardCommand;
6
7
class ParallelCommand extends AbstractStandardCommand
8
{
9
    public const TYPE = 'Parallel';
10
11
    /**
12
     * @param array|null $data Array of data to iterate over
13
     * @param AbstractStandardCommand[]|null $commands Commands to run in parallel
14
     */
15 7
    public function __construct(
16
        public ?array $data = null,
17
        public ?array $commands = null,
18
    ) {
19 7
        parent::__construct(self::TYPE);
20
    }
21
22 5
    public function jsonSerialize(): array
23
    {
24 5
        $data = parent::jsonSerialize();
25
26 5
        if ($this->data !== null && !empty($this->data)) {
27 2
            $data['data'] = $this->data;
28
        }
29
30 5
        if ($this->commands !== null && !empty($this->commands)) {
31 2
            $data['commands'] = $this->commands;
32
        }
33
34 5
        return $data;
35
    }
36
}
37