KeyHandler   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A jsonSerialize() 0 7 1
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 KeyHandler implements \JsonSerializable
10
{
11
    /**
12
     * @param AbstractStandardCommand[] $commands Commands to run when handler applies
13
     * @param bool $propagate Whether to propagate the event after handling
14
     * @param string|null $when APL boolean expression controlling whether this handler is considered
15
     */
16 14
    public function __construct(
17
        public array $commands = [],
18
        public bool $propagate = false,
19
        public ?string $when = null,
20
    ) {
21 14
    }
22
23 10
    public function jsonSerialize(): array
24
    {
25 10
        return array_filter([
26 10
            'commands' => $this->commands,
27 10
            'propagate' => $this->propagate,
28 10
            'when' => $this->when,
29 10
        ], fn ($value) => $value !== null);
30
    }
31
}
32