@@ -1,28 +1,28 @@ |
||
| 1 | -<?php |
|
| 1 | + <?php |
|
| 2 | 2 | |
| 3 | -declare(strict_types=1); |
|
| 3 | + declare(strict_types=1); |
|
| 4 | 4 | |
| 5 | -namespace MaxBeckers\AmazonAlexa\Response; |
|
| 5 | + namespace MaxBeckers\AmazonAlexa\Response; |
|
| 6 | 6 | |
| 7 | -class OutputSpeech |
|
| 8 | -{ |
|
| 9 | - public const TYPE_PLAINTEXT = 'PlainText'; |
|
| 10 | - public const TYPE_SSML = 'SSML'; |
|
| 7 | + class OutputSpeech |
|
| 8 | + { |
|
| 9 | + public const TYPE_PLAINTEXT = 'PlainText'; |
|
| 10 | + public const TYPE_SSML = 'SSML'; |
|
| 11 | 11 | |
| 12 | - public function __construct( |
|
| 13 | - public string $type = self::TYPE_PLAINTEXT, |
|
| 14 | - public ?string $text = null, |
|
| 15 | - public ?string $ssml = null |
|
| 16 | - ) { |
|
| 17 | - } |
|
| 12 | + public function __construct( |
|
| 13 | + public string $type = self::TYPE_PLAINTEXT, |
|
| 14 | + public ?string $text = null, |
|
| 15 | + public ?string $ssml = null |
|
| 16 | + ) { |
|
| 17 | + } |
|
| 18 | 18 | |
| 19 | - public static function createByText(string $text): self |
|
| 20 | - { |
|
| 21 | - return new self(text: $text); |
|
| 22 | - } |
|
| 19 | + public static function createByText(string $text): self |
|
| 20 | + { |
|
| 21 | + return new self(text: $text); |
|
| 22 | + } |
|
| 23 | 23 | |
| 24 | - public static function createBySsml(string $ssml): self |
|
| 25 | - { |
|
| 26 | - return new self(self::TYPE_SSML, ssml: $ssml); |
|
| 27 | - } |
|
| 24 | + public static function createBySsml(string $ssml): self |
|
| 25 | + { |
|
| 26 | + return new self(self::TYPE_SSML, ssml: $ssml); |
|
| 27 | + } |
|
| 28 | 28 | } |
@@ -1,40 +1,40 @@ |
||
| 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\Document; |
|
| 5 | + namespace MaxBeckers\AmazonAlexa\Response\Directives\APL\Document; |
|
| 6 | 6 | |
| 7 | -class StyleValue implements \JsonSerializable |
|
| 8 | -{ |
|
| 9 | - /** |
|
| 7 | + class StyleValue implements \JsonSerializable |
|
| 8 | + { |
|
| 9 | + /** |
|
| 10 | 10 | * When is an optional APL boolean expression controlling whether this style value block applies. |
| 11 | 11 | * If null, the block always applies. |
| 12 | 12 | */ |
| 13 | - public function __construct( |
|
| 14 | - public ?string $when = null, |
|
| 15 | - public array $properties = [], |
|
| 16 | - ) { |
|
| 17 | - } |
|
| 18 | - |
|
| 19 | - public function set(string $name, mixed $value): self |
|
| 20 | - { |
|
| 21 | - if ($name === 'when') { |
|
| 22 | - $this->when = is_string($value) ? $value : null; |
|
| 23 | - } else { |
|
| 24 | - $this->properties[$name] = $value; |
|
| 13 | + public function __construct( |
|
| 14 | + public ?string $when = null, |
|
| 15 | + public array $properties = [], |
|
| 16 | + ) { |
|
| 25 | 17 | } |
| 26 | 18 | |
| 27 | - return $this; |
|
| 28 | - } |
|
| 19 | + public function set(string $name, mixed $value): self |
|
| 20 | + { |
|
| 21 | + if ($name === 'when') { |
|
| 22 | + $this->when = is_string($value) ? $value : null; |
|
| 23 | + } else { |
|
| 24 | + $this->properties[$name] = $value; |
|
| 25 | + } |
|
| 29 | 26 | |
| 30 | - public function jsonSerialize(): array |
|
| 31 | - { |
|
| 32 | - $out = $this->properties; |
|
| 33 | - if ($this->when !== null && $this->when !== '') { |
|
| 34 | - // Ensure 'when' appears first for readability (JSON object order not semantically relevant). |
|
| 35 | - $out = ['when' => $this->when] + $out; |
|
| 27 | + return $this; |
|
| 36 | 28 | } |
| 37 | 29 | |
| 38 | - return $out; |
|
| 39 | - } |
|
| 30 | + public function jsonSerialize(): array |
|
| 31 | + { |
|
| 32 | + $out = $this->properties; |
|
| 33 | + if ($this->when !== null && $this->when !== '') { |
|
| 34 | + // Ensure 'when' appears first for readability (JSON object order not semantically relevant). |
|
| 35 | + $out = ['when' => $this->when] + $out; |
|
| 36 | + } |
|
| 37 | + |
|
| 38 | + return $out; |
|
| 39 | + } |
|
| 40 | 40 | } |
@@ -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\Document; |
|
| 5 | + namespace MaxBeckers\AmazonAlexa\Response\Directives\APL\Document; |
|
| 6 | 6 | |
| 7 | -use MaxBeckers\AmazonAlexa\Response\Directives\APL\StandardCommand\AbstractStandardCommand; |
|
| 7 | + use MaxBeckers\AmazonAlexa\Response\Directives\APL\StandardCommand\AbstractStandardCommand; |
|
| 8 | 8 | |
| 9 | -class VisibilityChangeHandler implements \JsonSerializable |
|
| 10 | -{ |
|
| 11 | - /** |
|
| 9 | + class VisibilityChangeHandler implements \JsonSerializable |
|
| 10 | + { |
|
| 11 | + /** |
|
| 12 | 12 | * @param AbstractStandardCommand[] $commands list of commands to run (evaluated in order) |
| 13 | 13 | * @param string|null $when APL boolean expression controlling whether this handler is considered. If null, treated as 'true'. |
| 14 | 14 | * @param string|null $description optional description of this handler |
| 15 | 15 | */ |
| 16 | - public function __construct( |
|
| 17 | - public array $commands = [], |
|
| 18 | - public ?string $when = null, |
|
| 19 | - public ?string $description = null, |
|
| 20 | - ) { |
|
| 21 | - // Filter and ensure valid commands |
|
| 22 | - $this->commands = array_values(array_filter( |
|
| 23 | - $this->commands, |
|
| 24 | - static fn ($c) => $c instanceof AbstractStandardCommand |
|
| 25 | - )); |
|
| 26 | - } |
|
| 27 | - |
|
| 28 | - public function jsonSerialize(): array |
|
| 29 | - { |
|
| 30 | - $data = []; |
|
| 31 | - if ($this->commands !== []) { |
|
| 32 | - $data['commands'] = $this->commands; |
|
| 33 | - } |
|
| 34 | - if ($this->description !== null && $this->description !== '') { |
|
| 35 | - $data['description'] = $this->description; |
|
| 36 | - } |
|
| 37 | - if ($this->when !== null && $this->when !== '') { |
|
| 38 | - $data['when'] = $this->when; |
|
| 16 | + public function __construct( |
|
| 17 | + public array $commands = [], |
|
| 18 | + public ?string $when = null, |
|
| 19 | + public ?string $description = null, |
|
| 20 | + ) { |
|
| 21 | + // Filter and ensure valid commands |
|
| 22 | + $this->commands = array_values(array_filter( |
|
| 23 | + $this->commands, |
|
| 24 | + static fn ($c) => $c instanceof AbstractStandardCommand |
|
| 25 | + )); |
|
| 39 | 26 | } |
| 40 | 27 | |
| 41 | - return $data; |
|
| 42 | - } |
|
| 28 | + public function jsonSerialize(): array |
|
| 29 | + { |
|
| 30 | + $data = []; |
|
| 31 | + if ($this->commands !== []) { |
|
| 32 | + $data['commands'] = $this->commands; |
|
| 33 | + } |
|
| 34 | + if ($this->description !== null && $this->description !== '') { |
|
| 35 | + $data['description'] = $this->description; |
|
| 36 | + } |
|
| 37 | + if ($this->when !== null && $this->when !== '') { |
|
| 38 | + $data['when'] = $this->when; |
|
| 39 | + } |
|
| 40 | + |
|
| 41 | + return $data; |
|
| 42 | + } |
|
| 43 | 43 | } |
@@ -1,11 +1,11 @@ |
||
| 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\Document; |
|
| 5 | + namespace MaxBeckers\AmazonAlexa\Response\Directives\APL\Document; |
|
| 6 | 6 | |
| 7 | -enum SetPagePosition: string |
|
| 8 | -{ |
|
| 9 | - case RELATIVE = 'relative'; |
|
| 10 | - case ABSOLUTE = 'absolute'; |
|
| 7 | + enum SetPagePosition: string |
|
| 8 | + { |
|
| 9 | + case RELATIVE = 'relative'; |
|
| 10 | + case ABSOLUTE = 'absolute'; |
|
| 11 | 11 | } |
@@ -1,34 +1,34 @@ |
||
| 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\Document; |
|
| 5 | + namespace MaxBeckers\AmazonAlexa\Response\Directives\APL\Document; |
|
| 6 | 6 | |
| 7 | -class LayoutParameter implements \JsonSerializable |
|
| 8 | -{ |
|
| 9 | - public function __construct( |
|
| 10 | - public string $name, |
|
| 11 | - public mixed $default = null, |
|
| 12 | - public ?string $description = null, |
|
| 13 | - public LayoutParameterType $type = LayoutParameterType::ANY, |
|
| 14 | - ) { |
|
| 15 | - } |
|
| 16 | - |
|
| 17 | - public function jsonSerialize(): array |
|
| 7 | + class LayoutParameter implements \JsonSerializable |
|
| 18 | 8 | { |
| 19 | - $data = [ |
|
| 20 | - 'name' => $this->name, |
|
| 21 | - 'type' => $this->type, |
|
| 22 | - ]; |
|
| 23 | - |
|
| 24 | - if ($this->default !== null) { |
|
| 25 | - $data['default'] = $this->default; |
|
| 9 | + public function __construct( |
|
| 10 | + public string $name, |
|
| 11 | + public mixed $default = null, |
|
| 12 | + public ?string $description = null, |
|
| 13 | + public LayoutParameterType $type = LayoutParameterType::ANY, |
|
| 14 | + ) { |
|
| 26 | 15 | } |
| 27 | 16 | |
| 28 | - if ($this->description !== null) { |
|
| 29 | - $data['description'] = $this->description; |
|
| 30 | - } |
|
| 17 | + public function jsonSerialize(): array |
|
| 18 | + { |
|
| 19 | + $data = [ |
|
| 20 | + 'name' => $this->name, |
|
| 21 | + 'type' => $this->type, |
|
| 22 | + ]; |
|
| 31 | 23 | |
| 32 | - return $data; |
|
| 33 | - } |
|
| 24 | + if ($this->default !== null) { |
|
| 25 | + $data['default'] = $this->default; |
|
| 26 | + } |
|
| 27 | + |
|
| 28 | + if ($this->description !== null) { |
|
| 29 | + $data['description'] = $this->description; |
|
| 30 | + } |
|
| 31 | + |
|
| 32 | + return $data; |
|
| 33 | + } |
|
| 34 | 34 | } |
@@ -1,16 +1,16 @@ |
||
| 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\Document; |
|
| 5 | + namespace MaxBeckers\AmazonAlexa\Response\Directives\APL\Document; |
|
| 6 | 6 | |
| 7 | -enum Snap: string |
|
| 8 | -{ |
|
| 9 | - case NONE = 'none'; |
|
| 10 | - case START = 'start'; |
|
| 11 | - case CENTER = 'center'; |
|
| 12 | - case END = 'end'; |
|
| 13 | - case FORCE_START = 'forceStart'; |
|
| 14 | - case FORCE_CENTER = 'forceCenter'; |
|
| 15 | - case FORCE_END = 'forceEnd'; |
|
| 7 | + enum Snap: string |
|
| 8 | + { |
|
| 9 | + case NONE = 'none'; |
|
| 10 | + case START = 'start'; |
|
| 11 | + case CENTER = 'center'; |
|
| 12 | + case END = 'end'; |
|
| 13 | + case FORCE_START = 'forceStart'; |
|
| 14 | + case FORCE_CENTER = 'forceCenter'; |
|
| 15 | + case FORCE_END = 'forceEnd'; |
|
| 16 | 16 | } |
@@ -1,28 +1,28 @@ |
||
| 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\Document; |
|
| 5 | + namespace MaxBeckers\AmazonAlexa\Response\Directives\APL\Document; |
|
| 6 | 6 | |
| 7 | -class PseudoLocalization implements \JsonSerializable |
|
| 8 | -{ |
|
| 9 | - public function __construct( |
|
| 10 | - public bool $enabled = false, |
|
| 11 | - public int $expansionPercentage = 30, |
|
| 12 | - ) { |
|
| 13 | - } |
|
| 14 | - |
|
| 15 | - public function jsonSerialize(): array |
|
| 7 | + class PseudoLocalization implements \JsonSerializable |
|
| 16 | 8 | { |
| 17 | - $data = []; |
|
| 18 | - |
|
| 19 | - if ($this->enabled) { |
|
| 20 | - $data['enabled'] = $this->enabled; |
|
| 21 | - } |
|
| 22 | - if ($this->expansionPercentage !== 30) { |
|
| 23 | - $data['expansionPercentage'] = $this->expansionPercentage; |
|
| 9 | + public function __construct( |
|
| 10 | + public bool $enabled = false, |
|
| 11 | + public int $expansionPercentage = 30, |
|
| 12 | + ) { |
|
| 24 | 13 | } |
| 25 | 14 | |
| 26 | - return $data; |
|
| 27 | - } |
|
| 15 | + public function jsonSerialize(): array |
|
| 16 | + { |
|
| 17 | + $data = []; |
|
| 18 | + |
|
| 19 | + if ($this->enabled) { |
|
| 20 | + $data['enabled'] = $this->enabled; |
|
| 21 | + } |
|
| 22 | + if ($this->expansionPercentage !== 30) { |
|
| 23 | + $data['expansionPercentage'] = $this->expansionPercentage; |
|
| 24 | + } |
|
| 25 | + |
|
| 26 | + return $data; |
|
| 27 | + } |
|
| 28 | 28 | } |
@@ -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\Document; |
|
| 5 | + namespace MaxBeckers\AmazonAlexa\Response\Directives\APL\Document; |
|
| 6 | 6 | |
| 7 | -enum ImageAlign: string |
|
| 8 | -{ |
|
| 9 | - case BOTTOM = 'bottom'; |
|
| 10 | - case BOTTOM_LEFT = 'bottom-left'; |
|
| 11 | - case BOTTOM_RIGHT = 'bottom-right'; |
|
| 12 | - case CENTER = 'center'; |
|
| 13 | - case LEFT = 'left'; |
|
| 14 | - case RIGHT = 'right'; |
|
| 15 | - case TOP = 'top'; |
|
| 16 | - case TOP_LEFT = 'top-left'; |
|
| 17 | - case TOP_RIGHT = 'top-right'; |
|
| 7 | + enum ImageAlign: string |
|
| 8 | + { |
|
| 9 | + case BOTTOM = 'bottom'; |
|
| 10 | + case BOTTOM_LEFT = 'bottom-left'; |
|
| 11 | + case BOTTOM_RIGHT = 'bottom-right'; |
|
| 12 | + case CENTER = 'center'; |
|
| 13 | + case LEFT = 'left'; |
|
| 14 | + case RIGHT = 'right'; |
|
| 15 | + case TOP = 'top'; |
|
| 16 | + case TOP_LEFT = 'top-left'; |
|
| 17 | + case TOP_RIGHT = 'top-right'; |
|
| 18 | 18 | } |
@@ -1,49 +1,49 @@ |
||
| 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; |
|
| 5 | + namespace MaxBeckers\AmazonAlexa\Response\Directives\APL; |
|
| 6 | 6 | |
| 7 | -use MaxBeckers\AmazonAlexa\Response\Directives\APL\StandardCommand\AbstractStandardCommand; |
|
| 8 | -use MaxBeckers\AmazonAlexa\Response\Directives\Directive; |
|
| 7 | + use MaxBeckers\AmazonAlexa\Response\Directives\APL\StandardCommand\AbstractStandardCommand; |
|
| 8 | + use MaxBeckers\AmazonAlexa\Response\Directives\Directive; |
|
| 9 | 9 | |
| 10 | -class ExecuteCommandsDirective extends Directive implements \JsonSerializable |
|
| 11 | -{ |
|
| 12 | - public const TYPE = 'Alexa.Presentation.APL.ExecuteCommands'; |
|
| 10 | + class ExecuteCommandsDirective extends Directive implements \JsonSerializable |
|
| 11 | + { |
|
| 12 | + public const TYPE = 'Alexa.Presentation.APL.ExecuteCommands'; |
|
| 13 | 13 | |
| 14 | - /** |
|
| 14 | + /** |
|
| 15 | 15 | * @param AbstractStandardCommand[] $commands Commands to run on the rendered document |
| 16 | 16 | * @param string|null $token Token that identifies the RenderDocument command (for standard APL documents) |
| 17 | 17 | * @param string|null $presentationUri String that identifies the widget to target with commands |
| 18 | 18 | */ |
| 19 | - public function __construct( |
|
| 20 | - public array $commands, |
|
| 21 | - public ?string $token = null, |
|
| 22 | - public ?string $presentationUri = null, |
|
| 23 | - ) { |
|
| 24 | - parent::__construct(); |
|
| 25 | - } |
|
| 26 | - |
|
| 27 | - public function addCommand(AbstractStandardCommand $command): void |
|
| 28 | - { |
|
| 29 | - $this->commands[] = $command; |
|
| 30 | - } |
|
| 31 | - |
|
| 32 | - public function jsonSerialize(): array |
|
| 33 | - { |
|
| 34 | - $data = [ |
|
| 35 | - 'type' => self::TYPE, |
|
| 36 | - 'commands' => $this->commands, |
|
| 37 | - ]; |
|
| 38 | - |
|
| 39 | - if ($this->token !== null) { |
|
| 40 | - $data['token'] = $this->token; |
|
| 19 | + public function __construct( |
|
| 20 | + public array $commands, |
|
| 21 | + public ?string $token = null, |
|
| 22 | + public ?string $presentationUri = null, |
|
| 23 | + ) { |
|
| 24 | + parent::__construct(); |
|
| 41 | 25 | } |
| 42 | 26 | |
| 43 | - if ($this->presentationUri !== null) { |
|
| 44 | - $data['presentationUri'] = $this->presentationUri; |
|
| 27 | + public function addCommand(AbstractStandardCommand $command): void |
|
| 28 | + { |
|
| 29 | + $this->commands[] = $command; |
|
| 45 | 30 | } |
| 46 | 31 | |
| 47 | - return $data; |
|
| 48 | - } |
|
| 32 | + public function jsonSerialize(): array |
|
| 33 | + { |
|
| 34 | + $data = [ |
|
| 35 | + 'type' => self::TYPE, |
|
| 36 | + 'commands' => $this->commands, |
|
| 37 | + ]; |
|
| 38 | + |
|
| 39 | + if ($this->token !== null) { |
|
| 40 | + $data['token'] = $this->token; |
|
| 41 | + } |
|
| 42 | + |
|
| 43 | + if ($this->presentationUri !== null) { |
|
| 44 | + $data['presentationUri'] = $this->presentationUri; |
|
| 45 | + } |
|
| 46 | + |
|
| 47 | + return $data; |
|
| 48 | + } |
|
| 49 | 49 | } |