Passed
Pull Request — master (#97)
by Maximilian
04:02
created

serializeActionableProperties()   B

Complexity

Conditions 9
Paths 16

Size

Total Lines 21
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 12.8936

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 9
eloc 10
nc 16
nop 0
dl 0
loc 21
ccs 7
cts 11
cp 0.6364
crap 12.8936
rs 8.0555
c 1
b 0
f 1
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 45
    protected function serializeActionableProperties(): array
22
    {
23 45
        $data = [];
24
25 45
        if ($this->onFocus !== null && !empty($this->onFocus)) {
26
            $data['onFocus'] = $this->onFocus;
27
        }
28
29 45
        if ($this->onBlur !== null && !empty($this->onBlur)) {
30
            $data['onBlur'] = $this->onBlur;
31
        }
32
33 45
        if ($this->handleKeyDown !== null && !empty($this->handleKeyDown)) {
34
            $data['handleKeyDown'] = $this->handleKeyDown;
35
        }
36
37 45
        if ($this->handleKeyUp !== null && !empty($this->handleKeyUp)) {
38
            $data['handleKeyUp'] = $this->handleKeyUp;
39
        }
40
41 45
        return $data;
42
    }
43
}
44