TouchWrapperComponent::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 1
nc 1
nop 2
dl 0
loc 5
ccs 2
cts 2
cp 1
crap 1
rs 10
c 1
b 0
f 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace MaxBeckers\AmazonAlexa\Response\Directives\APL\Component;
6
7
use MaxBeckers\AmazonAlexa\Response\Directives\APL\Document\APLComponentType;
8
9
class TouchWrapperComponent extends TouchableComponent implements \JsonSerializable
10
{
11
    public const TYPE = APLComponentType::TOUCH_WRAPPER;
12
13
    /**
14
     * @param APLBaseComponent|null $item Single child item to display
15
     * @param APLBaseComponent[]|null $items Array of child items to display
16
     */
17 10
    public function __construct(
18
        public ?APLBaseComponent $item = null,
19
        public ?array $items = null,
20
    ) {
21 10
        parent::__construct(self::TYPE);
22
    }
23
24 6
    public function jsonSerialize(): array
25
    {
26 6
        $data = parent::jsonSerialize();
27
28 6
        if ($this->item !== null) {
29 2
            $data['item'] = $this->item;
30
        }
31
32 6
        if (!empty($this->items)) {
33 2
            $data['items'] = $this->items;
34
        }
35
36 6
        return $data;
37
    }
38
}
39