Action   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
B jsonSerialize() 0 25 7
1
<?php
2
3
declare(strict_types=1);
4
5
namespace MaxBeckers\AmazonAlexa\Response\Directives\APL\Component;
6
7
use MaxBeckers\AmazonAlexa\Response\Directives\APL\StandardCommand\AbstractStandardCommand;
8
9
class Action implements \JsonSerializable
10
{
11
    /**
12
     * @param AbstractStandardCommand|null $command Single command to run
13
     * @param AbstractStandardCommand[]|null $commands Array of commands to run
14
     * @param bool $enabled Whether the action is enabled
15
     * @param string|null $label Label for the action
16
     * @param string|null $name Name of the action
17
     */
18 8
    public function __construct(
19
        public ?AbstractStandardCommand $command = null,
20
        public ?array $commands = null,
21
        public bool $enabled = true,
22
        public ?string $label = null,
23
        public ?string $name = null,
24
    ) {
25 8
    }
26
27 5
    public function jsonSerialize(): array
28
    {
29 5
        $data = [];
30
31 5
        if ($this->command !== null) {
32 1
            $data['command'] = $this->command;
33
        }
34
35 5
        if ($this->commands !== null && !empty($this->commands)) {
36 1
            $data['commands'] = $this->commands;
37
        }
38
39 5
        if (!$this->enabled) {
40 2
            $data['enabled'] = $this->enabled;
41
        }
42
43 5
        if ($this->label !== null) {
44 1
            $data['label'] = $this->label;
45
        }
46
47 5
        if ($this->name !== null) {
48 1
            $data['name'] = $this->name;
49
        }
50
51 5
        return $data;
52
    }
53
}
54