SendEventCommand::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 1
nc 1
nop 3
dl 0
loc 6
ccs 2
cts 2
cp 1
crap 1
rs 10
c 1
b 0
f 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