TouchWrapperComponent   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A jsonSerialize() 0 13 3
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