|
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\AlignItems; |
|
8
|
|
|
use MaxBeckers\AmazonAlexa\Response\Directives\APL\Document\APLComponentType; |
|
9
|
|
|
use MaxBeckers\AmazonAlexa\Response\Directives\APL\Document\Direction; |
|
10
|
|
|
use MaxBeckers\AmazonAlexa\Response\Directives\APL\Document\JustifyContent; |
|
11
|
|
|
use MaxBeckers\AmazonAlexa\Response\Directives\APL\Document\Wrap; |
|
12
|
|
|
|
|
13
|
|
|
class ContainerComponent extends MultiChildComponent implements \JsonSerializable |
|
14
|
|
|
{ |
|
15
|
|
|
public const TYPE = APLComponentType::CONTAINER; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* @param AlignItems|null $alignItems Alignment for children in the cross-axis |
|
19
|
|
|
* @param Direction|null $direction Direction in which to display the child components |
|
20
|
|
|
* @param JustifyContent|null $justifyContent How to distribute free space when there is room on the main axis |
|
21
|
|
|
* @param bool $numbered When true, assign ordinal numbers to children |
|
22
|
|
|
* @param Wrap|null $wrap Determines how to wrap child components to multiple lines |
|
23
|
|
|
*/ |
|
24
|
8 |
|
public function __construct( |
|
25
|
|
|
public ?AlignItems $alignItems = null, |
|
26
|
|
|
public ?Direction $direction = null, |
|
27
|
|
|
public ?JustifyContent $justifyContent = null, |
|
28
|
|
|
public bool $numbered = false, |
|
29
|
|
|
public ?Wrap $wrap = null, |
|
30
|
|
|
) { |
|
31
|
8 |
|
parent::__construct(self::TYPE); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
4 |
|
public function jsonSerialize(): array |
|
35
|
|
|
{ |
|
36
|
4 |
|
$data = parent::jsonSerialize(); |
|
37
|
|
|
|
|
38
|
4 |
|
if ($this->alignItems !== null) { |
|
39
|
1 |
|
$data['alignItems'] = $this->alignItems->value; |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
4 |
|
if ($this->direction !== null) { |
|
43
|
1 |
|
$data['direction'] = $this->direction->value; |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
4 |
|
if ($this->justifyContent !== null) { |
|
47
|
1 |
|
$data['justifyContent'] = $this->justifyContent->value; |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
4 |
|
if ($this->numbered) { |
|
51
|
2 |
|
$data['numbered'] = $this->numbered; |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
4 |
|
if ($this->wrap !== null) { |
|
55
|
1 |
|
$data['wrap'] = $this->wrap->value; |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
4 |
|
return $data; |
|
59
|
|
|
} |
|
60
|
|
|
} |
|
61
|
|
|
|