SendEventCommand   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
B jsonSerialize() 0 17 7
A __construct() 0 6 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace MaxBeckers\AmazonAlexa\Response\Directives\APL\StandardCommand;
6
7
class SendEventCommand extends AbstractStandardCommand implements \JsonSerializable
8
{
9
    public const TYPE = 'SendEvent';
10
11
    /**
12
     * @param array|null $arguments Array of arguments to send with the event
13
     * @param array|null $components Array of components related to the event
14
     * @param array|null $flags Flags including interaction mode settings
15
     */
16 7
    public function __construct(
17
        public ?array $arguments = null,
18
        public ?array $components = null,
19
        public ?array $flags = null,
20
    ) {
21 7
        parent::__construct(self::TYPE);
22
    }
23
24 5
    public function jsonSerialize(): array
25
    {
26 5
        $data = parent::jsonSerialize();
27
28 5
        if ($this->arguments !== null && !empty($this->arguments)) {
29 3
            $data['arguments'] = $this->arguments;
30
        }
31
32 5
        if ($this->components !== null && !empty($this->components)) {
33 2
            $data['components'] = $this->components;
34
        }
35
36 5
        if ($this->flags !== null && !empty($this->flags)) {
37 2
            $data['flags'] = $this->flags;
38
        }
39
40 5
        return $data;
41
    }
42
}
43