Passed
Push — master ( a53d55...43aca1 )
by Maximilian
03:50
created

Layout   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 8
dl 0
loc 27
ccs 10
cts 10
cp 1
rs 10
c 1
b 0
f 1
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A jsonSerialize() 0 9 1
A __construct() 0 7 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace MaxBeckers\AmazonAlexa\Response\Directives\APL\Document;
6
7
use MaxBeckers\AmazonAlexa\Response\Directives\APL\Component\APLBaseComponent;
8
9
class Layout implements \JsonSerializable
10
{
11
    /**
12
     * @param Bind[]|null $bind Array of binding objects
13
     * @param string|null $description Optional description of this layout
14
     * @param APLBaseComponent|null $item Single component to display
15
     * @param APLBaseComponent[]|null $items Array of components to display
16
     * @param LayoutParameter[]|null $parameters Array of layout parameters
17
     */
18 12
    public function __construct(
19
        public ?array $bind = null,
20
        public ?string $description = null,
21
        public ?APLBaseComponent $item = null,
22
        public ?array $items = null,
23
        public ?array $parameters = null,
24
    ) {
25 12
    }
26
27 7
    public function jsonSerialize(): array
28
    {
29 7
        return array_filter([
30 7
            'bind' => $this->bind,
31 7
            'description' => $this->description,
32 7
            'item' => $this->item,
33 7
            'items' => $this->items,
34 7
            'parameters' => $this->parameters,
35 7
        ], fn ($value) => $value !== null);
36
    }
37
}
38