@@ -1,51 +1,51 @@ |
||
| 1 | -<?php |
|
| 1 | + <?php |
|
| 2 | 2 | |
| 3 | -declare(strict_types=1); |
|
| 3 | + declare(strict_types=1); |
|
| 4 | 4 | |
| 5 | -namespace MaxBeckers\AmazonAlexa\Response\Directives\APL\Component; |
|
| 5 | + namespace MaxBeckers\AmazonAlexa\Response\Directives\APL\Component; |
|
| 6 | 6 | |
| 7 | -use MaxBeckers\AmazonAlexa\Response\Directives\APL\Document\APLComponentType; |
|
| 8 | -use MaxBeckers\AmazonAlexa\Response\Directives\APL\StandardCommand\AbstractStandardCommand; |
|
| 7 | + use MaxBeckers\AmazonAlexa\Response\Directives\APL\Document\APLComponentType; |
|
| 8 | + use MaxBeckers\AmazonAlexa\Response\Directives\APL\StandardCommand\AbstractStandardCommand; |
|
| 9 | 9 | |
| 10 | -class ScrollViewComponent extends ActionableComponent implements \JsonSerializable |
|
| 11 | -{ |
|
| 12 | - public const TYPE = APLComponentType::SCROLL_VIEW; |
|
| 10 | + class ScrollViewComponent extends ActionableComponent implements \JsonSerializable |
|
| 11 | + { |
|
| 12 | + public const TYPE = APLComponentType::SCROLL_VIEW; |
|
| 13 | 13 | |
| 14 | - /** |
|
| 14 | + /** |
|
| 15 | 15 | * @param APLBaseComponent|null $item Single component displayed in the ScrollView |
| 16 | 16 | * @param APLBaseComponent[]|null $items Array of components displayed in the ScrollView |
| 17 | 17 | * @param string[]|null $preserve Properties to save when reinflating the document |
| 18 | 18 | * @param AbstractStandardCommand[]|null $onScroll Commands to run during scrolling |
| 19 | 19 | */ |
| 20 | - public function __construct( |
|
| 21 | - public ?APLBaseComponent $item = null, |
|
| 22 | - public ?array $items = null, |
|
| 23 | - ?array $preserve = null, |
|
| 24 | - public ?array $onScroll = null, |
|
| 25 | - ) { |
|
| 26 | - parent::__construct(type: self::TYPE, preserve: $preserve); |
|
| 27 | - } |
|
| 28 | - |
|
| 29 | - public function jsonSerialize(): array |
|
| 30 | - { |
|
| 31 | - $data = parent::jsonSerialize(); |
|
| 32 | - |
|
| 33 | - if ($this->item !== null) { |
|
| 34 | - $data['item'] = $this->item; |
|
| 20 | + public function __construct( |
|
| 21 | + public ?APLBaseComponent $item = null, |
|
| 22 | + public ?array $items = null, |
|
| 23 | + ?array $preserve = null, |
|
| 24 | + public ?array $onScroll = null, |
|
| 25 | + ) { |
|
| 26 | + parent::__construct(type: self::TYPE, preserve: $preserve); |
|
| 35 | 27 | } |
| 36 | 28 | |
| 37 | - if ($this->items !== null && !empty($this->items)) { |
|
| 38 | - $data['items'] = $this->items; |
|
| 39 | - } |
|
| 29 | + public function jsonSerialize(): array |
|
| 30 | + { |
|
| 31 | + $data = parent::jsonSerialize(); |
|
| 40 | 32 | |
| 41 | - if ($this->preserve !== null && !empty($this->preserve)) { |
|
| 42 | - $data['preserve'] = $this->preserve; |
|
| 43 | - } |
|
| 33 | + if ($this->item !== null) { |
|
| 34 | + $data['item'] = $this->item; |
|
| 35 | + } |
|
| 44 | 36 | |
| 45 | - if ($this->onScroll !== null && !empty($this->onScroll)) { |
|
| 46 | - $data['onScroll'] = $this->onScroll; |
|
| 47 | - } |
|
| 37 | + if ($this->items !== null && !empty($this->items)) { |
|
| 38 | + $data['items'] = $this->items; |
|
| 39 | + } |
|
| 40 | + |
|
| 41 | + if ($this->preserve !== null && !empty($this->preserve)) { |
|
| 42 | + $data['preserve'] = $this->preserve; |
|
| 43 | + } |
|
| 48 | 44 | |
| 49 | - return $data; |
|
| 50 | - } |
|
| 45 | + if ($this->onScroll !== null && !empty($this->onScroll)) { |
|
| 46 | + $data['onScroll'] = $this->onScroll; |
|
| 47 | + } |
|
| 48 | + |
|
| 49 | + return $data; |
|
| 50 | + } |
|
| 51 | 51 | } |
@@ -1,68 +1,68 @@ |
||
| 1 | -<?php |
|
| 1 | + <?php |
|
| 2 | 2 | |
| 3 | -declare(strict_types=1); |
|
| 3 | + declare(strict_types=1); |
|
| 4 | 4 | |
| 5 | -namespace MaxBeckers\AmazonAlexa\Response\Directives\APL\Component; |
|
| 5 | + namespace MaxBeckers\AmazonAlexa\Response\Directives\APL\Component; |
|
| 6 | 6 | |
| 7 | -use MaxBeckers\AmazonAlexa\Request\ScrollDirection; |
|
| 8 | -use MaxBeckers\AmazonAlexa\Response\Directives\APL\Component\Traits\ActionableComponentTrait; |
|
| 9 | -use MaxBeckers\AmazonAlexa\Response\Directives\APL\Component\Traits\MultiChildComponentTrait; |
|
| 10 | -use MaxBeckers\AmazonAlexa\Response\Directives\APL\Document\APLComponentType; |
|
| 11 | -use MaxBeckers\AmazonAlexa\Response\Directives\APL\Document\Snap; |
|
| 12 | -use MaxBeckers\AmazonAlexa\Response\Directives\APL\StandardCommand\AbstractStandardCommand; |
|
| 7 | + use MaxBeckers\AmazonAlexa\Request\ScrollDirection; |
|
| 8 | + use MaxBeckers\AmazonAlexa\Response\Directives\APL\Component\Traits\ActionableComponentTrait; |
|
| 9 | + use MaxBeckers\AmazonAlexa\Response\Directives\APL\Component\Traits\MultiChildComponentTrait; |
|
| 10 | + use MaxBeckers\AmazonAlexa\Response\Directives\APL\Document\APLComponentType; |
|
| 11 | + use MaxBeckers\AmazonAlexa\Response\Directives\APL\Document\Snap; |
|
| 12 | + use MaxBeckers\AmazonAlexa\Response\Directives\APL\StandardCommand\AbstractStandardCommand; |
|
| 13 | 13 | |
| 14 | -class SequenceComponent extends APLBaseComponent implements \JsonSerializable |
|
| 15 | -{ |
|
| 16 | - use ActionableComponentTrait; |
|
| 17 | - use MultiChildComponentTrait; |
|
| 14 | + class SequenceComponent extends APLBaseComponent implements \JsonSerializable |
|
| 15 | + { |
|
| 16 | + use ActionableComponentTrait; |
|
| 17 | + use MultiChildComponentTrait; |
|
| 18 | 18 | |
| 19 | - public const TYPE = APLComponentType::SEQUENCE; |
|
| 19 | + public const TYPE = APLComponentType::SEQUENCE; |
|
| 20 | 20 | |
| 21 | - /** |
|
| 21 | + /** |
|
| 22 | 22 | * @param bool $numbered When true, assign ordinal numbers to the Sequence children |
| 23 | 23 | * @param AbstractStandardCommand[]|null $onScroll Commands to run during scrolling |
| 24 | 24 | * @param string[]|null $preserve Properties to save when reinflating the document |
| 25 | 25 | * @param ScrollDirection|null $scrollDirection The direction to scroll this Sequence |
| 26 | 26 | * @param Snap|null $snap The alignment that the child components snap to when scrolling stops |
| 27 | 27 | */ |
| 28 | - public function __construct( |
|
| 29 | - public bool $numbered = false, |
|
| 30 | - public ?array $onScroll = null, |
|
| 31 | - ?array $preserve = null, |
|
| 32 | - public ?ScrollDirection $scrollDirection = null, |
|
| 33 | - public ?Snap $snap = null, |
|
| 34 | - ) { |
|
| 35 | - parent::__construct(type: self::TYPE, preserve: $preserve); |
|
| 36 | - } |
|
| 28 | + public function __construct( |
|
| 29 | + public bool $numbered = false, |
|
| 30 | + public ?array $onScroll = null, |
|
| 31 | + ?array $preserve = null, |
|
| 32 | + public ?ScrollDirection $scrollDirection = null, |
|
| 33 | + public ?Snap $snap = null, |
|
| 34 | + ) { |
|
| 35 | + parent::__construct(type: self::TYPE, preserve: $preserve); |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | - public function jsonSerialize(): array |
|
| 39 | - { |
|
| 40 | - $data = array_merge( |
|
| 41 | - parent::jsonSerialize(), |
|
| 42 | - $this->serializeActionableProperties(), |
|
| 43 | - $this->serializeMultiChildProperties() |
|
| 44 | - ); |
|
| 38 | + public function jsonSerialize(): array |
|
| 39 | + { |
|
| 40 | + $data = array_merge( |
|
| 41 | + parent::jsonSerialize(), |
|
| 42 | + $this->serializeActionableProperties(), |
|
| 43 | + $this->serializeMultiChildProperties() |
|
| 44 | + ); |
|
| 45 | 45 | |
| 46 | - if ($this->numbered) { |
|
| 47 | - $data['numbered'] = $this->numbered; |
|
| 48 | - } |
|
| 46 | + if ($this->numbered) { |
|
| 47 | + $data['numbered'] = $this->numbered; |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | - if ($this->onScroll !== null && !empty($this->onScroll)) { |
|
| 51 | - $data['onScroll'] = $this->onScroll; |
|
| 52 | - } |
|
| 50 | + if ($this->onScroll !== null && !empty($this->onScroll)) { |
|
| 51 | + $data['onScroll'] = $this->onScroll; |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - if ($this->preserve !== null && !empty($this->preserve)) { |
|
| 55 | - $data['preserve'] = $this->preserve; |
|
| 56 | - } |
|
| 54 | + if ($this->preserve !== null && !empty($this->preserve)) { |
|
| 55 | + $data['preserve'] = $this->preserve; |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - if ($this->scrollDirection !== null) { |
|
| 59 | - $data['scrollDirection'] = $this->scrollDirection->value; |
|
| 60 | - } |
|
| 58 | + if ($this->scrollDirection !== null) { |
|
| 59 | + $data['scrollDirection'] = $this->scrollDirection->value; |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - if ($this->snap !== null) { |
|
| 63 | - $data['snap'] = $this->snap->value; |
|
| 64 | - } |
|
| 62 | + if ($this->snap !== null) { |
|
| 63 | + $data['snap'] = $this->snap->value; |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | - return $data; |
|
| 67 | - } |
|
| 66 | + return $data; |
|
| 67 | + } |
|
| 68 | 68 | } |
@@ -1,18 +1,18 @@ |
||
| 1 | -<?php |
|
| 1 | + <?php |
|
| 2 | 2 | |
| 3 | -declare(strict_types=1); |
|
| 3 | + declare(strict_types=1); |
|
| 4 | 4 | |
| 5 | -namespace MaxBeckers\AmazonAlexa\Response\Directives\APL\Component; |
|
| 5 | + namespace MaxBeckers\AmazonAlexa\Response\Directives\APL\Component; |
|
| 6 | 6 | |
| 7 | -use MaxBeckers\AmazonAlexa\Response\Directives\APL\Component\Traits\MultiChildComponentTrait; |
|
| 8 | -use MaxBeckers\AmazonAlexa\Response\Directives\APL\Document\APLComponentType; |
|
| 7 | + use MaxBeckers\AmazonAlexa\Response\Directives\APL\Component\Traits\MultiChildComponentTrait; |
|
| 8 | + use MaxBeckers\AmazonAlexa\Response\Directives\APL\Document\APLComponentType; |
|
| 9 | 9 | |
| 10 | -abstract class MultiChildComponent extends APLBaseComponent |
|
| 11 | -{ |
|
| 12 | - use MultiChildComponentTrait; |
|
| 13 | - |
|
| 14 | - public function __construct(APLComponentType $type) |
|
| 10 | + abstract class MultiChildComponent extends APLBaseComponent |
|
| 15 | 11 | { |
| 16 | - parent::__construct($type); |
|
| 17 | - } |
|
| 12 | + use MultiChildComponentTrait; |
|
| 13 | + |
|
| 14 | + public function __construct(APLComponentType $type) |
|
| 15 | + { |
|
| 16 | + parent::__construct($type); |
|
| 17 | + } |
|
| 18 | 18 | } |
@@ -1,69 +1,69 @@ |
||
| 1 | -<?php |
|
| 1 | + <?php |
|
| 2 | 2 | |
| 3 | -declare(strict_types=1); |
|
| 3 | + declare(strict_types=1); |
|
| 4 | 4 | |
| 5 | -namespace MaxBeckers\AmazonAlexa\Response\Directives\APL\Component; |
|
| 5 | + namespace MaxBeckers\AmazonAlexa\Response\Directives\APL\Component; |
|
| 6 | 6 | |
| 7 | -use MaxBeckers\AmazonAlexa\Request\ScrollDirection; |
|
| 8 | -use MaxBeckers\AmazonAlexa\Response\Directives\APL\Component\Traits\ActionableComponentTrait; |
|
| 9 | -use MaxBeckers\AmazonAlexa\Response\Directives\APL\Component\Traits\MultiChildComponentTrait; |
|
| 10 | -use MaxBeckers\AmazonAlexa\Response\Directives\APL\Document\APLComponentType; |
|
| 11 | -use MaxBeckers\AmazonAlexa\Response\Directives\APL\Document\FlexAlignItems; |
|
| 12 | -use MaxBeckers\AmazonAlexa\Response\Directives\APL\Document\Snap; |
|
| 13 | -use MaxBeckers\AmazonAlexa\Response\Directives\APL\StandardCommand\AbstractStandardCommand; |
|
| 7 | + use MaxBeckers\AmazonAlexa\Request\ScrollDirection; |
|
| 8 | + use MaxBeckers\AmazonAlexa\Response\Directives\APL\Component\Traits\ActionableComponentTrait; |
|
| 9 | + use MaxBeckers\AmazonAlexa\Response\Directives\APL\Component\Traits\MultiChildComponentTrait; |
|
| 10 | + use MaxBeckers\AmazonAlexa\Response\Directives\APL\Document\APLComponentType; |
|
| 11 | + use MaxBeckers\AmazonAlexa\Response\Directives\APL\Document\FlexAlignItems; |
|
| 12 | + use MaxBeckers\AmazonAlexa\Response\Directives\APL\Document\Snap; |
|
| 13 | + use MaxBeckers\AmazonAlexa\Response\Directives\APL\StandardCommand\AbstractStandardCommand; |
|
| 14 | 14 | |
| 15 | -class FlexSequenceComponent extends APLBaseComponent implements \JsonSerializable |
|
| 16 | -{ |
|
| 17 | - use ActionableComponentTrait; |
|
| 18 | - use MultiChildComponentTrait; |
|
| 15 | + class FlexSequenceComponent extends APLBaseComponent implements \JsonSerializable |
|
| 16 | + { |
|
| 17 | + use ActionableComponentTrait; |
|
| 18 | + use MultiChildComponentTrait; |
|
| 19 | 19 | |
| 20 | - public const TYPE = APLComponentType::FLEX_SEQUENCE; |
|
| 20 | + public const TYPE = APLComponentType::FLEX_SEQUENCE; |
|
| 21 | 21 | |
| 22 | - /** |
|
| 22 | + /** |
|
| 23 | 23 | * @param FlexAlignItems|null $alignItems Alignment for children in the cross-axis |
| 24 | 24 | * @param bool $numbered When true, assign ordinal numbers to the FlexSequence children |
| 25 | 25 | * @param AbstractStandardCommand[]|null $onScroll Commands to run when scrolling |
| 26 | 26 | * @param ScrollDirection|null $scrollDirection The direction to scroll this FlexSequence |
| 27 | 27 | * @param Snap|null $snap The alignment that the child components snap to when scrolling stops |
| 28 | 28 | */ |
| 29 | - public function __construct( |
|
| 30 | - public ?FlexAlignItems $alignItems = null, |
|
| 31 | - public bool $numbered = false, |
|
| 32 | - public ?array $onScroll = null, |
|
| 33 | - public ?ScrollDirection $scrollDirection = null, |
|
| 34 | - public ?Snap $snap = null, |
|
| 35 | - ) { |
|
| 36 | - parent::__construct(self::TYPE); |
|
| 37 | - } |
|
| 29 | + public function __construct( |
|
| 30 | + public ?FlexAlignItems $alignItems = null, |
|
| 31 | + public bool $numbered = false, |
|
| 32 | + public ?array $onScroll = null, |
|
| 33 | + public ?ScrollDirection $scrollDirection = null, |
|
| 34 | + public ?Snap $snap = null, |
|
| 35 | + ) { |
|
| 36 | + parent::__construct(self::TYPE); |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - public function jsonSerialize(): array |
|
| 40 | - { |
|
| 41 | - $data = array_merge( |
|
| 42 | - parent::jsonSerialize(), |
|
| 43 | - $this->serializeActionableProperties(), |
|
| 44 | - $this->serializeMultiChildProperties() |
|
| 45 | - ); |
|
| 39 | + public function jsonSerialize(): array |
|
| 40 | + { |
|
| 41 | + $data = array_merge( |
|
| 42 | + parent::jsonSerialize(), |
|
| 43 | + $this->serializeActionableProperties(), |
|
| 44 | + $this->serializeMultiChildProperties() |
|
| 45 | + ); |
|
| 46 | 46 | |
| 47 | - if ($this->alignItems !== null) { |
|
| 48 | - $data['alignItems'] = $this->alignItems->value; |
|
| 49 | - } |
|
| 47 | + if ($this->alignItems !== null) { |
|
| 48 | + $data['alignItems'] = $this->alignItems->value; |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - if ($this->numbered) { |
|
| 52 | - $data['numbered'] = $this->numbered; |
|
| 53 | - } |
|
| 51 | + if ($this->numbered) { |
|
| 52 | + $data['numbered'] = $this->numbered; |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - if ($this->onScroll !== null && !empty($this->onScroll)) { |
|
| 56 | - $data['onScroll'] = $this->onScroll; |
|
| 57 | - } |
|
| 55 | + if ($this->onScroll !== null && !empty($this->onScroll)) { |
|
| 56 | + $data['onScroll'] = $this->onScroll; |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | - if ($this->scrollDirection !== null) { |
|
| 60 | - $data['scrollDirection'] = $this->scrollDirection->value; |
|
| 61 | - } |
|
| 59 | + if ($this->scrollDirection !== null) { |
|
| 60 | + $data['scrollDirection'] = $this->scrollDirection->value; |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - if ($this->snap !== null) { |
|
| 64 | - $data['snap'] = $this->snap->value; |
|
| 65 | - } |
|
| 63 | + if ($this->snap !== null) { |
|
| 64 | + $data['snap'] = $this->snap->value; |
|
| 65 | + } |
|
| 66 | 66 | |
| 67 | - return $data; |
|
| 68 | - } |
|
| 67 | + return $data; |
|
| 68 | + } |
|
| 69 | 69 | } |
@@ -1,43 +1,43 @@ |
||
| 1 | -<?php |
|
| 1 | + <?php |
|
| 2 | 2 | |
| 3 | -declare(strict_types=1); |
|
| 3 | + declare(strict_types=1); |
|
| 4 | 4 | |
| 5 | -namespace MaxBeckers\AmazonAlexa\Response\Directives\APL\Component\Traits; |
|
| 5 | + namespace MaxBeckers\AmazonAlexa\Response\Directives\APL\Component\Traits; |
|
| 6 | 6 | |
| 7 | -use MaxBeckers\AmazonAlexa\Response\Directives\APL\Document\KeyHandler; |
|
| 8 | -use MaxBeckers\AmazonAlexa\Response\Directives\APL\StandardCommand\AbstractStandardCommand; |
|
| 7 | + use MaxBeckers\AmazonAlexa\Response\Directives\APL\Document\KeyHandler; |
|
| 8 | + use MaxBeckers\AmazonAlexa\Response\Directives\APL\StandardCommand\AbstractStandardCommand; |
|
| 9 | 9 | |
| 10 | -trait ActionableComponentTrait |
|
| 11 | -{ |
|
| 12 | - /** @var AbstractStandardCommand[]|null */ |
|
| 13 | - public ?array $onFocus = null; |
|
| 14 | - /** @var AbstractStandardCommand[]|null */ |
|
| 15 | - public ?array $onBlur = null; |
|
| 16 | - /** @var KeyHandler[]|null */ |
|
| 17 | - public ?array $handleKeyDown = null; |
|
| 18 | - /** @var KeyHandler[]|null */ |
|
| 19 | - public ?array $handleKeyUp = null; |
|
| 20 | - |
|
| 21 | - protected function serializeActionableProperties(): array |
|
| 10 | + trait ActionableComponentTrait |
|
| 22 | 11 | { |
| 23 | - $data = []; |
|
| 24 | - |
|
| 25 | - if ($this->onFocus !== null && !empty($this->onFocus)) { |
|
| 26 | - $data['onFocus'] = $this->onFocus; |
|
| 12 | + /** @var AbstractStandardCommand[]|null */ |
|
| 13 | + public ?array $onFocus = null; |
|
| 14 | + /** @var AbstractStandardCommand[]|null */ |
|
| 15 | + public ?array $onBlur = null; |
|
| 16 | + /** @var KeyHandler[]|null */ |
|
| 17 | + public ?array $handleKeyDown = null; |
|
| 18 | + /** @var KeyHandler[]|null */ |
|
| 19 | + public ?array $handleKeyUp = null; |
|
| 20 | + |
|
| 21 | + protected function serializeActionableProperties(): array |
|
| 22 | + { |
|
| 23 | + $data = []; |
|
| 24 | + |
|
| 25 | + if ($this->onFocus !== null && !empty($this->onFocus)) { |
|
| 26 | + $data['onFocus'] = $this->onFocus; |
|
| 27 | + } |
|
| 28 | + |
|
| 29 | + if ($this->onBlur !== null && !empty($this->onBlur)) { |
|
| 30 | + $data['onBlur'] = $this->onBlur; |
|
| 31 | + } |
|
| 32 | + |
|
| 33 | + if ($this->handleKeyDown !== null && !empty($this->handleKeyDown)) { |
|
| 34 | + $data['handleKeyDown'] = $this->handleKeyDown; |
|
| 35 | + } |
|
| 36 | + |
|
| 37 | + if ($this->handleKeyUp !== null && !empty($this->handleKeyUp)) { |
|
| 38 | + $data['handleKeyUp'] = $this->handleKeyUp; |
|
| 39 | + } |
|
| 40 | + |
|
| 41 | + return $data; |
|
| 27 | 42 | } |
| 28 | - |
|
| 29 | - if ($this->onBlur !== null && !empty($this->onBlur)) { |
|
| 30 | - $data['onBlur'] = $this->onBlur; |
|
| 31 | - } |
|
| 32 | - |
|
| 33 | - if ($this->handleKeyDown !== null && !empty($this->handleKeyDown)) { |
|
| 34 | - $data['handleKeyDown'] = $this->handleKeyDown; |
|
| 35 | - } |
|
| 36 | - |
|
| 37 | - if ($this->handleKeyUp !== null && !empty($this->handleKeyUp)) { |
|
| 38 | - $data['handleKeyUp'] = $this->handleKeyUp; |
|
| 39 | - } |
|
| 40 | - |
|
| 41 | - return $data; |
|
| 42 | - } |
|
| 43 | 43 | } |
@@ -1,35 +1,35 @@ |
||
| 1 | -<?php |
|
| 1 | + <?php |
|
| 2 | 2 | |
| 3 | -declare(strict_types=1); |
|
| 3 | + declare(strict_types=1); |
|
| 4 | 4 | |
| 5 | -namespace MaxBeckers\AmazonAlexa\Response\Directives\APL\Component\Traits; |
|
| 5 | + namespace MaxBeckers\AmazonAlexa\Response\Directives\APL\Component\Traits; |
|
| 6 | 6 | |
| 7 | -use MaxBeckers\AmazonAlexa\Response\Directives\APL\Component\APLBaseComponent; |
|
| 7 | + use MaxBeckers\AmazonAlexa\Response\Directives\APL\Component\APLBaseComponent; |
|
| 8 | 8 | |
| 9 | -trait MultiChildComponentTrait |
|
| 10 | -{ |
|
| 11 | - public ?array $data = null; |
|
| 12 | - /** @var APLBaseComponent|APLBaseComponent[]|null */ |
|
| 13 | - public $item = null; |
|
| 14 | - /** @var APLBaseComponent[]|null */ |
|
| 15 | - public ?array $items = null; |
|
| 16 | - |
|
| 17 | - protected function serializeMultiChildProperties(): array |
|
| 9 | + trait MultiChildComponentTrait |
|
| 18 | 10 | { |
| 19 | - $data = []; |
|
| 11 | + public ?array $data = null; |
|
| 12 | + /** @var APLBaseComponent|APLBaseComponent[]|null */ |
|
| 13 | + public $item = null; |
|
| 14 | + /** @var APLBaseComponent[]|null */ |
|
| 15 | + public ?array $items = null; |
|
| 20 | 16 | |
| 21 | - if ($this->data !== null && !empty($this->data)) { |
|
| 22 | - $data['data'] = $this->data; |
|
| 23 | - } |
|
| 17 | + protected function serializeMultiChildProperties(): array |
|
| 18 | + { |
|
| 19 | + $data = []; |
|
| 24 | 20 | |
| 25 | - if ($this->item !== null) { |
|
| 26 | - $data['item'] = $this->item; |
|
| 27 | - } |
|
| 21 | + if ($this->data !== null && !empty($this->data)) { |
|
| 22 | + $data['data'] = $this->data; |
|
| 23 | + } |
|
| 28 | 24 | |
| 29 | - if ($this->items !== null && !empty($this->items)) { |
|
| 30 | - $data['items'] = $this->items; |
|
| 31 | - } |
|
| 25 | + if ($this->item !== null) { |
|
| 26 | + $data['item'] = $this->item; |
|
| 27 | + } |
|
| 28 | + |
|
| 29 | + if ($this->items !== null && !empty($this->items)) { |
|
| 30 | + $data['items'] = $this->items; |
|
| 31 | + } |
|
| 32 | 32 | |
| 33 | - return $data; |
|
| 34 | - } |
|
| 33 | + return $data; |
|
| 34 | + } |
|
| 35 | 35 | } |
@@ -1,19 +1,19 @@ discard block |
||
| 1 | -<?php |
|
| 1 | + <?php |
|
| 2 | 2 | |
| 3 | -declare(strict_types=1); |
|
| 3 | + declare(strict_types=1); |
|
| 4 | 4 | |
| 5 | -namespace MaxBeckers\AmazonAlexa\Response\Directives\APL\Component; |
|
| 5 | + namespace MaxBeckers\AmazonAlexa\Response\Directives\APL\Component; |
|
| 6 | 6 | |
| 7 | -use MaxBeckers\AmazonAlexa\Response\Directives\APL\Document\APLComponentType; |
|
| 8 | -use MaxBeckers\AmazonAlexa\Response\Directives\APL\Document\ImageAlign; |
|
| 9 | -use MaxBeckers\AmazonAlexa\Response\Directives\APL\Document\Scale; |
|
| 10 | -use MaxBeckers\AmazonAlexa\Response\Directives\APL\StandardCommand\AbstractStandardCommand; |
|
| 7 | + use MaxBeckers\AmazonAlexa\Response\Directives\APL\Document\APLComponentType; |
|
| 8 | + use MaxBeckers\AmazonAlexa\Response\Directives\APL\Document\ImageAlign; |
|
| 9 | + use MaxBeckers\AmazonAlexa\Response\Directives\APL\Document\Scale; |
|
| 10 | + use MaxBeckers\AmazonAlexa\Response\Directives\APL\StandardCommand\AbstractStandardCommand; |
|
| 11 | 11 | |
| 12 | -class VectorGraphicComponent extends TouchableComponent implements \JsonSerializable |
|
| 13 | -{ |
|
| 14 | - public const TYPE = APLComponentType::VECTOR_GRAPHIC; |
|
| 12 | + class VectorGraphicComponent extends TouchableComponent implements \JsonSerializable |
|
| 13 | + { |
|
| 14 | + public const TYPE = APLComponentType::VECTOR_GRAPHIC; |
|
| 15 | 15 | |
| 16 | - /** |
|
| 16 | + /** |
|
| 17 | 17 | * @param ImageAlign|null $align Alignment of the vector graphic within the component |
| 18 | 18 | * @param AbstractStandardCommand[]|null $onFail Commands to run when the source fails to load |
| 19 | 19 | * @param AbstractStandardCommand[]|null $onLoad Commands to run after the source loads |
@@ -21,45 +21,45 @@ discard block |
||
| 21 | 21 | * @param Scale|null $scale How the vector graphic scales up or down within the component |
| 22 | 22 | * @param string|null $source The URL or direct reference to a vector graphic |
| 23 | 23 | */ |
| 24 | - public function __construct( |
|
| 25 | - public ?ImageAlign $align = null, |
|
| 26 | - public ?array $onFail = null, |
|
| 27 | - public ?array $onLoad = null, |
|
| 28 | - public ?array $parameters = null, |
|
| 29 | - public ?Scale $scale = null, |
|
| 30 | - public ?string $source = null, |
|
| 31 | - ) { |
|
| 32 | - parent::__construct(self::TYPE); |
|
| 33 | - } |
|
| 24 | + public function __construct( |
|
| 25 | + public ?ImageAlign $align = null, |
|
| 26 | + public ?array $onFail = null, |
|
| 27 | + public ?array $onLoad = null, |
|
| 28 | + public ?array $parameters = null, |
|
| 29 | + public ?Scale $scale = null, |
|
| 30 | + public ?string $source = null, |
|
| 31 | + ) { |
|
| 32 | + parent::__construct(self::TYPE); |
|
| 33 | + } |
|
| 34 | 34 | |
| 35 | - public function jsonSerialize(): array |
|
| 36 | - { |
|
| 37 | - $data = parent::jsonSerialize(); |
|
| 35 | + public function jsonSerialize(): array |
|
| 36 | + { |
|
| 37 | + $data = parent::jsonSerialize(); |
|
| 38 | 38 | |
| 39 | - if ($this->align !== null) { |
|
| 40 | - $data['align'] = $this->align->value; |
|
| 41 | - } |
|
| 39 | + if ($this->align !== null) { |
|
| 40 | + $data['align'] = $this->align->value; |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - if ($this->onFail !== null && !empty($this->onFail)) { |
|
| 44 | - $data['onFail'] = $this->onFail; |
|
| 45 | - } |
|
| 43 | + if ($this->onFail !== null && !empty($this->onFail)) { |
|
| 44 | + $data['onFail'] = $this->onFail; |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - if ($this->onLoad !== null && !empty($this->onLoad)) { |
|
| 48 | - $data['onLoad'] = $this->onLoad; |
|
| 49 | - } |
|
| 47 | + if ($this->onLoad !== null && !empty($this->onLoad)) { |
|
| 48 | + $data['onLoad'] = $this->onLoad; |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - if ($this->parameters !== null && !empty($this->parameters)) { |
|
| 52 | - $data['parameters'] = $this->parameters; |
|
| 53 | - } |
|
| 51 | + if ($this->parameters !== null && !empty($this->parameters)) { |
|
| 52 | + $data['parameters'] = $this->parameters; |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - if ($this->scale !== null) { |
|
| 56 | - $data['scale'] = $this->scale->value; |
|
| 57 | - } |
|
| 55 | + if ($this->scale !== null) { |
|
| 56 | + $data['scale'] = $this->scale->value; |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | - if ($this->source !== null) { |
|
| 60 | - $data['source'] = $this->source; |
|
| 61 | - } |
|
| 59 | + if ($this->source !== null) { |
|
| 60 | + $data['source'] = $this->source; |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - return $data; |
|
| 64 | - } |
|
| 63 | + return $data; |
|
| 64 | + } |
|
| 65 | 65 | } |
@@ -1,39 +1,39 @@ |
||
| 1 | -<?php |
|
| 1 | + <?php |
|
| 2 | 2 | |
| 3 | -declare(strict_types=1); |
|
| 3 | + declare(strict_types=1); |
|
| 4 | 4 | |
| 5 | -namespace MaxBeckers\AmazonAlexa\Response\Directives\APL\Component; |
|
| 5 | + namespace MaxBeckers\AmazonAlexa\Response\Directives\APL\Component; |
|
| 6 | 6 | |
| 7 | -class Entity implements \JsonSerializable |
|
| 8 | -{ |
|
| 9 | - /** |
|
| 7 | + class Entity implements \JsonSerializable |
|
| 8 | + { |
|
| 9 | + /** |
|
| 10 | 10 | * @param string|null $id Entity identifier |
| 11 | 11 | * @param string|null $type Entity type |
| 12 | 12 | * @param mixed $value Entity value |
| 13 | 13 | */ |
| 14 | - public function __construct( |
|
| 15 | - public ?string $id = null, |
|
| 16 | - public ?string $type = null, |
|
| 17 | - public mixed $value = null, |
|
| 18 | - ) { |
|
| 19 | - } |
|
| 20 | - |
|
| 21 | - public function jsonSerialize(): array |
|
| 22 | - { |
|
| 23 | - $data = []; |
|
| 24 | - |
|
| 25 | - if ($this->id !== null) { |
|
| 26 | - $data['id'] = $this->id; |
|
| 14 | + public function __construct( |
|
| 15 | + public ?string $id = null, |
|
| 16 | + public ?string $type = null, |
|
| 17 | + public mixed $value = null, |
|
| 18 | + ) { |
|
| 27 | 19 | } |
| 28 | 20 | |
| 29 | - if ($this->type !== null) { |
|
| 30 | - $data['type'] = $this->type; |
|
| 31 | - } |
|
| 21 | + public function jsonSerialize(): array |
|
| 22 | + { |
|
| 23 | + $data = []; |
|
| 32 | 24 | |
| 33 | - if ($this->value !== null) { |
|
| 34 | - $data['value'] = $this->value; |
|
| 35 | - } |
|
| 25 | + if ($this->id !== null) { |
|
| 26 | + $data['id'] = $this->id; |
|
| 27 | + } |
|
| 28 | + |
|
| 29 | + if ($this->type !== null) { |
|
| 30 | + $data['type'] = $this->type; |
|
| 31 | + } |
|
| 36 | 32 | |
| 37 | - return $data; |
|
| 38 | - } |
|
| 33 | + if ($this->value !== null) { |
|
| 34 | + $data['value'] = $this->value; |
|
| 35 | + } |
|
| 36 | + |
|
| 37 | + return $data; |
|
| 38 | + } |
|
| 39 | 39 | } |
@@ -1,24 +1,24 @@ discard block |
||
| 1 | -<?php |
|
| 1 | + <?php |
|
| 2 | 2 | |
| 3 | -declare(strict_types=1); |
|
| 3 | + declare(strict_types=1); |
|
| 4 | 4 | |
| 5 | -namespace MaxBeckers\AmazonAlexa\Response\Directives\APL\Component; |
|
| 5 | + namespace MaxBeckers\AmazonAlexa\Response\Directives\APL\Component; |
|
| 6 | 6 | |
| 7 | -use MaxBeckers\AmazonAlexa\Response\Directives\APL\Component\Traits\ActionableComponentTrait; |
|
| 8 | -use MaxBeckers\AmazonAlexa\Response\Directives\APL\Component\Traits\MultiChildComponentTrait; |
|
| 9 | -use MaxBeckers\AmazonAlexa\Response\Directives\APL\Document\APLComponentType; |
|
| 10 | -use MaxBeckers\AmazonAlexa\Response\Directives\APL\Document\Navigation; |
|
| 11 | -use MaxBeckers\AmazonAlexa\Response\Directives\APL\Document\PageDirection; |
|
| 12 | -use MaxBeckers\AmazonAlexa\Response\Directives\APL\StandardCommand\AbstractStandardCommand; |
|
| 7 | + use MaxBeckers\AmazonAlexa\Response\Directives\APL\Component\Traits\ActionableComponentTrait; |
|
| 8 | + use MaxBeckers\AmazonAlexa\Response\Directives\APL\Component\Traits\MultiChildComponentTrait; |
|
| 9 | + use MaxBeckers\AmazonAlexa\Response\Directives\APL\Document\APLComponentType; |
|
| 10 | + use MaxBeckers\AmazonAlexa\Response\Directives\APL\Document\Navigation; |
|
| 11 | + use MaxBeckers\AmazonAlexa\Response\Directives\APL\Document\PageDirection; |
|
| 12 | + use MaxBeckers\AmazonAlexa\Response\Directives\APL\StandardCommand\AbstractStandardCommand; |
|
| 13 | 13 | |
| 14 | -class PagerComponent extends APLBaseComponent implements \JsonSerializable |
|
| 15 | -{ |
|
| 16 | - use ActionableComponentTrait; |
|
| 17 | - use MultiChildComponentTrait; |
|
| 14 | + class PagerComponent extends APLBaseComponent implements \JsonSerializable |
|
| 15 | + { |
|
| 16 | + use ActionableComponentTrait; |
|
| 17 | + use MultiChildComponentTrait; |
|
| 18 | 18 | |
| 19 | - public const TYPE = APLComponentType::PAGER; |
|
| 19 | + public const TYPE = APLComponentType::PAGER; |
|
| 20 | 20 | |
| 21 | - /** |
|
| 21 | + /** |
|
| 22 | 22 | * @param array|null $handlePageMove Handlers to run when the Pager changes pages |
| 23 | 23 | * @param int $initialPage The index of the starting page (0-based) |
| 24 | 24 | * @param Navigation|null $navigation Specifies the allowed navigation direction |
@@ -26,49 +26,49 @@ discard block |
||
| 26 | 26 | * @param PageDirection|null $pageDirection The direction to move pages |
| 27 | 27 | * @param string[]|null $preserve Properties to save when reinflating the document |
| 28 | 28 | */ |
| 29 | - public function __construct( |
|
| 30 | - public ?array $handlePageMove = null, |
|
| 31 | - public int $initialPage = 0, |
|
| 32 | - public ?Navigation $navigation = null, |
|
| 33 | - public ?array $onPageChanged = null, |
|
| 34 | - public ?PageDirection $pageDirection = null, |
|
| 35 | - ?array $preserve = null, |
|
| 36 | - ) { |
|
| 37 | - parent::__construct(type: self::TYPE, preserve: $preserve); |
|
| 38 | - } |
|
| 29 | + public function __construct( |
|
| 30 | + public ?array $handlePageMove = null, |
|
| 31 | + public int $initialPage = 0, |
|
| 32 | + public ?Navigation $navigation = null, |
|
| 33 | + public ?array $onPageChanged = null, |
|
| 34 | + public ?PageDirection $pageDirection = null, |
|
| 35 | + ?array $preserve = null, |
|
| 36 | + ) { |
|
| 37 | + parent::__construct(type: self::TYPE, preserve: $preserve); |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | - public function jsonSerialize(): array |
|
| 41 | - { |
|
| 42 | - $data = array_merge( |
|
| 43 | - parent::jsonSerialize(), |
|
| 44 | - $this->serializeActionableProperties(), |
|
| 45 | - $this->serializeMultiChildProperties() |
|
| 46 | - ); |
|
| 40 | + public function jsonSerialize(): array |
|
| 41 | + { |
|
| 42 | + $data = array_merge( |
|
| 43 | + parent::jsonSerialize(), |
|
| 44 | + $this->serializeActionableProperties(), |
|
| 45 | + $this->serializeMultiChildProperties() |
|
| 46 | + ); |
|
| 47 | 47 | |
| 48 | - if ($this->handlePageMove !== null && !empty($this->handlePageMove)) { |
|
| 49 | - $data['handlePageMove'] = $this->handlePageMove; |
|
| 50 | - } |
|
| 48 | + if ($this->handlePageMove !== null && !empty($this->handlePageMove)) { |
|
| 49 | + $data['handlePageMove'] = $this->handlePageMove; |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - if ($this->initialPage !== 0) { |
|
| 53 | - $data['initialPage'] = $this->initialPage; |
|
| 54 | - } |
|
| 52 | + if ($this->initialPage !== 0) { |
|
| 53 | + $data['initialPage'] = $this->initialPage; |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | - if ($this->navigation !== null) { |
|
| 57 | - $data['navigation'] = $this->navigation->value; |
|
| 58 | - } |
|
| 56 | + if ($this->navigation !== null) { |
|
| 57 | + $data['navigation'] = $this->navigation->value; |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | - if ($this->onPageChanged !== null && !empty($this->onPageChanged)) { |
|
| 61 | - $data['onPageChanged'] = $this->onPageChanged; |
|
| 62 | - } |
|
| 60 | + if ($this->onPageChanged !== null && !empty($this->onPageChanged)) { |
|
| 61 | + $data['onPageChanged'] = $this->onPageChanged; |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - if ($this->pageDirection !== null) { |
|
| 65 | - $data['pageDirection'] = $this->pageDirection->value; |
|
| 66 | - } |
|
| 64 | + if ($this->pageDirection !== null) { |
|
| 65 | + $data['pageDirection'] = $this->pageDirection->value; |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - if ($this->preserve !== null && !empty($this->preserve)) { |
|
| 69 | - $data['preserve'] = $this->preserve; |
|
| 70 | - } |
|
| 68 | + if ($this->preserve !== null && !empty($this->preserve)) { |
|
| 69 | + $data['preserve'] = $this->preserve; |
|
| 70 | + } |
|
| 71 | 71 | |
| 72 | - return $data; |
|
| 73 | - } |
|
| 72 | + return $data; |
|
| 73 | + } |
|
| 74 | 74 | } |