ActionableComponentTrait   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Test Coverage

Coverage 81.82%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 15
c 1
b 0
f 1
dl 0
loc 32
ccs 9
cts 11
cp 0.8182
rs 10
wmc 9

1 Method

Rating   Name   Duplication   Size   Complexity  
B serializeActionableProperties() 0 21 9
1
<?php
2
3
declare(strict_types=1);
4
5
namespace MaxBeckers\AmazonAlexa\Response\Directives\APL\Component\Traits;
6
7
use MaxBeckers\AmazonAlexa\Response\Directives\APL\Document\KeyHandler;
8
use MaxBeckers\AmazonAlexa\Response\Directives\APL\StandardCommand\AbstractStandardCommand;
9
10
trait ActionableComponentTrait
11
{
12
    /** @var AbstractStandardCommand[]|null */
13
    public ?array $onFocus = null;
14
    /** @var AbstractStandardCommand[]|null */
15
    public ?array $onBlur = null;
16
    /** @var KeyHandler[]|null */
17
    public ?array $handleKeyDown = null;
18
    /** @var KeyHandler[]|null */
19
    public ?array $handleKeyUp = null;
20
21 47
    protected function serializeActionableProperties(): array
22
    {
23 47
        $data = [];
24
25 47
        if ($this->onFocus !== null && !empty($this->onFocus)) {
26 1
            $data['onFocus'] = $this->onFocus;
27
        }
28
29 47
        if ($this->onBlur !== null && !empty($this->onBlur)) {
30 1
            $data['onBlur'] = $this->onBlur;
31
        }
32
33 47
        if ($this->handleKeyDown !== null && !empty($this->handleKeyDown)) {
34
            $data['handleKeyDown'] = $this->handleKeyDown;
35
        }
36
37 47
        if ($this->handleKeyUp !== null && !empty($this->handleKeyUp)) {
38
            $data['handleKeyUp'] = $this->handleKeyUp;
39
        }
40
41 47
        return $data;
42
    }
43
}
44