Passed
Pull Request — master (#97)
by Maximilian
03:52
created

Command   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A jsonSerialize() 0 21 5
1
<?php
2
3
declare(strict_types=1);
4
5
namespace MaxBeckers\AmazonAlexa\Response\Directives\APL\Document;
6
7
use MaxBeckers\AmazonAlexa\Response\Directives\APL\StandardCommand\AbstractStandardCommand;
8
9
class Command implements \JsonSerializable
10
{
11
    /**
12
     * @param Parameter[]|null $parameters Array of parameter definitions
13
     * @param AbstractStandardCommand|null $command Single command to run
14
     * @param AbstractStandardCommand[]|null $commands Array of commands to run
15
     * @param string|null $description Description of this command
16
     */
17 10
    public function __construct(
18
        public ?array $parameters = null,
19
        public ?AbstractStandardCommand $command = null,
20
        public ?array $commands = null,
21
        public ?string $description = null,
22
    ) {
23 10
    }
24
25 6
    public function jsonSerialize(): array
26
    {
27 6
        $data = [];
28
29 6
        if ($this->parameters !== null) {
30 2
            $data['parameters'] = $this->parameters;
31
        }
32
33 6
        if ($this->command !== null) {
34 2
            $data['command'] = $this->command;
35
        }
36
37 6
        if ($this->commands !== null) {
38 2
            $data['commands'] = $this->commands;
39
        }
40
41 6
        if ($this->description !== null) {
42 3
            $data['description'] = $this->description;
43
        }
44
45 6
        return $data;
46
    }
47
}
48