serializeActionableProperties()   B
last analyzed

Complexity

Conditions 9
Paths 16

Size

Total Lines 21
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 9.4867

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 9
eloc 10
c 1
b 0
f 1
nc 16
nop 0
dl 0
loc 21
ccs 9
cts 11
cp 0.8182
crap 9.4867
rs 8.0555
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