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

Tap   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 6
dl 0
loc 24
ccs 7
cts 7
cp 1
rs 10
c 1
b 0
f 1
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A jsonSerialize() 0 9 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace MaxBeckers\AmazonAlexa\Response\Directives\APL\Gesture;
6
7
use MaxBeckers\AmazonAlexa\Response\Directives\APL\Document\GestureType;
8
use MaxBeckers\AmazonAlexa\Response\Directives\APL\StandardCommand\AbstractStandardCommand;
9
10
class Tap extends AbstractGesture
11
{
12
    /**
13
     * @param AbstractStandardCommand[]|null $onTap Commands to run when a tap occurs
14
     * @param AbstractStandardCommand[]|null $onCancel Commands to run when gesture is cancelled
15
     * @param bool|null $when APL boolean expression controlling whether this gesture is active
16
     */
17 5
    public function __construct(
18
        public ?array $onTap = null,
19
        ?array $onCancel = null,
20
        ?bool $when = null,
21
    ) {
22 5
        parent::__construct(GestureType::TAP, $onCancel, $when);
23
    }
24
25 3
    public function jsonSerialize(): array
26
    {
27 3
        $data = parent::jsonSerialize();
28
29 3
        if ($this->onTap !== null && !empty($this->onTap)) {
30 1
            $data['onTap'] = $this->onTap;
31
        }
32
33 3
        return $data;
34
    }
35
}
36