@@ -13,8 +13,7 @@ |
||
| 13 | 13 | /** |
| 14 | 14 | * This is a validator for amazon echo requests. It validates the timestamp of the request and the request signature. |
| 15 | 15 | */ |
| 16 | -class RequestValidator |
|
| 17 | -{ |
|
| 16 | +class RequestValidator { |
|
| 18 | 17 | /** |
| 19 | 18 | * Basic value for timestamp validation. 150 seconds is suggested by amazon. |
| 20 | 19 | */ |
@@ -1,73 +1,73 @@ discard block |
||
| 1 | -<?php |
|
| 1 | + <?php |
|
| 2 | 2 | |
| 3 | -declare(strict_types=1); |
|
| 3 | + declare(strict_types=1); |
|
| 4 | 4 | |
| 5 | -namespace MaxBeckers\AmazonAlexa\Validation; |
|
| 5 | + namespace MaxBeckers\AmazonAlexa\Validation; |
|
| 6 | 6 | |
| 7 | -use GuzzleHttp\Client; |
|
| 8 | -use MaxBeckers\AmazonAlexa\Exception\OutdatedCertExceptionException; |
|
| 9 | -use MaxBeckers\AmazonAlexa\Exception\RequestInvalidSignatureException; |
|
| 10 | -use MaxBeckers\AmazonAlexa\Exception\RequestInvalidTimestampException; |
|
| 11 | -use MaxBeckers\AmazonAlexa\Request\Request; |
|
| 7 | + use GuzzleHttp\Client; |
|
| 8 | + use MaxBeckers\AmazonAlexa\Exception\OutdatedCertExceptionException; |
|
| 9 | + use MaxBeckers\AmazonAlexa\Exception\RequestInvalidSignatureException; |
|
| 10 | + use MaxBeckers\AmazonAlexa\Exception\RequestInvalidTimestampException; |
|
| 11 | + use MaxBeckers\AmazonAlexa\Request\Request; |
|
| 12 | 12 | |
| 13 | 13 | /** |
| 14 | 14 | * This is a validator for amazon echo requests. It validates the timestamp of the request and the request signature. |
| 15 | 15 | */ |
| 16 | -class RequestValidator |
|
| 17 | -{ |
|
| 18 | - /** |
|
| 16 | + class RequestValidator |
|
| 17 | + { |
|
| 18 | + /** |
|
| 19 | 19 | * Basic value for timestamp validation. 150 seconds is suggested by amazon. |
| 20 | 20 | */ |
| 21 | - public const TIMESTAMP_VALID_TOLERANCE_SECONDS = 150; |
|
| 21 | + public const TIMESTAMP_VALID_TOLERANCE_SECONDS = 150; |
|
| 22 | 22 | |
| 23 | - /** |
|
| 23 | + /** |
|
| 24 | 24 | * @param int $timestampTolerance Timestamp tolerance in seconds |
| 25 | 25 | * @param Client $client HTTP client for fetching certificates |
| 26 | 26 | */ |
| 27 | - public function __construct( |
|
| 28 | - protected int $timestampTolerance = self::TIMESTAMP_VALID_TOLERANCE_SECONDS, |
|
| 29 | - public Client $client = new Client(), |
|
| 30 | - ) { |
|
| 31 | - } |
|
| 27 | + public function __construct( |
|
| 28 | + protected int $timestampTolerance = self::TIMESTAMP_VALID_TOLERANCE_SECONDS, |
|
| 29 | + public Client $client = new Client(), |
|
| 30 | + ) { |
|
| 31 | + } |
|
| 32 | 32 | |
| 33 | - /** |
|
| 33 | + /** |
|
| 34 | 34 | * Validate request data. |
| 35 | 35 | * |
| 36 | 36 | * @throws OutdatedCertExceptionException |
| 37 | 37 | * @throws RequestInvalidSignatureException |
| 38 | 38 | * @throws RequestInvalidTimestampException |
| 39 | 39 | */ |
| 40 | - public function validate(Request $request): void |
|
| 41 | - { |
|
| 42 | - $this->validateTimestamp($request); |
|
| 43 | - try { |
|
| 44 | - $this->validateSignature($request); |
|
| 45 | - } catch (OutdatedCertExceptionException $e) { |
|
| 46 | - // load cert again and validate because temp file was outdated. |
|
| 47 | - $this->validateSignature($request); |
|
| 40 | + public function validate(Request $request): void |
|
| 41 | + { |
|
| 42 | + $this->validateTimestamp($request); |
|
| 43 | + try { |
|
| 44 | + $this->validateSignature($request); |
|
| 45 | + } catch (OutdatedCertExceptionException $e) { |
|
| 46 | + // load cert again and validate because temp file was outdated. |
|
| 47 | + $this->validateSignature($request); |
|
| 48 | + } |
|
| 48 | 49 | } |
| 49 | - } |
|
| 50 | 50 | |
| 51 | - /** |
|
| 51 | + /** |
|
| 52 | 52 | * Validate request timestamp. Request tolerance should be 150 seconds. |
| 53 | 53 | * For more details @see https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/developing-an-alexa-skill-as-a-web-service#timestamp. |
| 54 | 54 | * |
| 55 | 55 | * @throws RequestInvalidTimestampException |
| 56 | 56 | */ |
| 57 | - private function validateTimestamp(Request $request): void |
|
| 58 | - { |
|
| 59 | - if (null === $request->request || !$request->request->validateTimestamp()) { |
|
| 60 | - return; |
|
| 61 | - } |
|
| 57 | + private function validateTimestamp(Request $request): void |
|
| 58 | + { |
|
| 59 | + if (null === $request->request || !$request->request->validateTimestamp()) { |
|
| 60 | + return; |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - $differenceInSeconds = time() - $request->request->timestamp?->getTimestamp(); |
|
| 63 | + $differenceInSeconds = time() - $request->request->timestamp?->getTimestamp(); |
|
| 64 | 64 | |
| 65 | - if ($differenceInSeconds > $this->timestampTolerance) { |
|
| 66 | - throw new RequestInvalidTimestampException('Invalid timestamp.'); |
|
| 65 | + if ($differenceInSeconds > $this->timestampTolerance) { |
|
| 66 | + throw new RequestInvalidTimestampException('Invalid timestamp.'); |
|
| 67 | + } |
|
| 67 | 68 | } |
| 68 | - } |
|
| 69 | 69 | |
| 70 | - /** |
|
| 70 | + /** |
|
| 71 | 71 | * Validate request signature. The steps for signature validation are described at developer page. |
| 72 | 72 | * |
| 73 | 73 | * @see https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/developing-an-alexa-skill-as-a-web-service#checking-the-signature-of-the-request |
@@ -75,117 +75,117 @@ discard block |
||
| 75 | 75 | * @throws OutdatedCertExceptionException |
| 76 | 76 | * @throws RequestInvalidSignatureException |
| 77 | 77 | */ |
| 78 | - private function validateSignature(Request $request): void |
|
| 79 | - { |
|
| 80 | - if (null === $request->request || !$request->request->validateSignature()) { |
|
| 81 | - return; |
|
| 82 | - } |
|
| 78 | + private function validateSignature(Request $request): void |
|
| 79 | + { |
|
| 80 | + if (null === $request->request || !$request->request->validateSignature()) { |
|
| 81 | + return; |
|
| 82 | + } |
|
| 83 | 83 | |
| 84 | - // validate cert url |
|
| 85 | - $this->validateCertUrl($request); |
|
| 84 | + // validate cert url |
|
| 85 | + $this->validateCertUrl($request); |
|
| 86 | 86 | |
| 87 | - // generate local cert path |
|
| 88 | - $localCertPath = sys_get_temp_dir() . DIRECTORY_SEPARATOR . md5($request->signatureCertChainUrl) . '.pem'; |
|
| 87 | + // generate local cert path |
|
| 88 | + $localCertPath = sys_get_temp_dir() . DIRECTORY_SEPARATOR . md5($request->signatureCertChainUrl) . '.pem'; |
|
| 89 | 89 | |
| 90 | - // check if pem file is already downloaded to temp or download. |
|
| 91 | - $certData = $this->fetchCertData($request, $localCertPath); |
|
| 90 | + // check if pem file is already downloaded to temp or download. |
|
| 91 | + $certData = $this->fetchCertData($request, $localCertPath); |
|
| 92 | 92 | |
| 93 | - // openssl cert validation |
|
| 94 | - $this->verifyCert($request, $certData); |
|
| 93 | + // openssl cert validation |
|
| 94 | + $this->verifyCert($request, $certData); |
|
| 95 | 95 | |
| 96 | - // parse cert |
|
| 97 | - $certContent = $this->parseCertData($certData); |
|
| 96 | + // parse cert |
|
| 97 | + $certContent = $this->parseCertData($certData); |
|
| 98 | 98 | |
| 99 | - // validate cert |
|
| 100 | - $this->validateCertContent($certContent, $localCertPath); |
|
| 101 | - } |
|
| 99 | + // validate cert |
|
| 100 | + $this->validateCertContent($certContent, $localCertPath); |
|
| 101 | + } |
|
| 102 | 102 | |
| 103 | - /** |
|
| 103 | + /** |
|
| 104 | 104 | * @throws RequestInvalidSignatureException |
| 105 | 105 | */ |
| 106 | - private function validateCertUrl(Request $request): void |
|
| 107 | - { |
|
| 108 | - if (false === (bool) preg_match("/https:\/\/s3.amazonaws.com(\:443)?\/echo.api\/*/i", $request->signatureCertChainUrl)) { |
|
| 109 | - throw new RequestInvalidSignatureException('Invalid cert url.'); |
|
| 106 | + private function validateCertUrl(Request $request): void |
|
| 107 | + { |
|
| 108 | + if (false === (bool) preg_match("/https:\/\/s3.amazonaws.com(\:443)?\/echo.api\/*/i", $request->signatureCertChainUrl)) { |
|
| 109 | + throw new RequestInvalidSignatureException('Invalid cert url.'); |
|
| 110 | + } |
|
| 110 | 111 | } |
| 111 | - } |
|
| 112 | 112 | |
| 113 | - /** |
|
| 113 | + /** |
|
| 114 | 114 | * @throws RequestInvalidSignatureException |
| 115 | 115 | */ |
| 116 | - private function fetchCertData(Request $request, string $localCertPath): string |
|
| 117 | - { |
|
| 118 | - if (!file_exists($localCertPath)) { |
|
| 119 | - $response = $this->client->request('GET', $request->signatureCertChainUrl); |
|
| 120 | - |
|
| 121 | - if ($response->getStatusCode() !== 200) { |
|
| 122 | - throw new RequestInvalidSignatureException('Can\'t fetch cert from URL.'); |
|
| 116 | + private function fetchCertData(Request $request, string $localCertPath): string |
|
| 117 | + { |
|
| 118 | + if (!file_exists($localCertPath)) { |
|
| 119 | + $response = $this->client->request('GET', $request->signatureCertChainUrl); |
|
| 120 | + |
|
| 121 | + if ($response->getStatusCode() !== 200) { |
|
| 122 | + throw new RequestInvalidSignatureException('Can\'t fetch cert from URL.'); |
|
| 123 | + } |
|
| 124 | + |
|
| 125 | + $certData = $response->getBody()->getContents(); |
|
| 126 | + @file_put_contents($localCertPath, $certData); |
|
| 127 | + } else { |
|
| 128 | + $certData = @file_get_contents($localCertPath); |
|
| 123 | 129 | } |
| 124 | 130 | |
| 125 | - $certData = $response->getBody()->getContents(); |
|
| 126 | - @file_put_contents($localCertPath, $certData); |
|
| 127 | - } else { |
|
| 128 | - $certData = @file_get_contents($localCertPath); |
|
| 131 | + return $certData; |
|
| 129 | 132 | } |
| 130 | 133 | |
| 131 | - return $certData; |
|
| 132 | - } |
|
| 133 | - |
|
| 134 | - /** |
|
| 134 | + /** |
|
| 135 | 135 | * @throws RequestInvalidSignatureException |
| 136 | 136 | */ |
| 137 | - private function verifyCert(Request $request, string $certData): void |
|
| 138 | - { |
|
| 139 | - if (1 !== @openssl_verify($request->amazonRequestBody, base64_decode($request->signature, true), $certData, 'sha1')) { |
|
| 140 | - throw new RequestInvalidSignatureException('Cert ssl verification failed.'); |
|
| 137 | + private function verifyCert(Request $request, string $certData): void |
|
| 138 | + { |
|
| 139 | + if (1 !== @openssl_verify($request->amazonRequestBody, base64_decode($request->signature, true), $certData, 'sha1')) { |
|
| 140 | + throw new RequestInvalidSignatureException('Cert ssl verification failed.'); |
|
| 141 | + } |
|
| 141 | 142 | } |
| 142 | - } |
|
| 143 | 143 | |
| 144 | - /** |
|
| 144 | + /** |
|
| 145 | 145 | * @throws RequestInvalidSignatureException |
| 146 | 146 | */ |
| 147 | - private function parseCertData(string $certData): array |
|
| 148 | - { |
|
| 149 | - $certContent = @openssl_x509_parse($certData); |
|
| 150 | - if (empty($certContent)) { |
|
| 151 | - throw new RequestInvalidSignatureException('Parse cert failed.'); |
|
| 152 | - } |
|
| 147 | + private function parseCertData(string $certData): array |
|
| 148 | + { |
|
| 149 | + $certContent = @openssl_x509_parse($certData); |
|
| 150 | + if (empty($certContent)) { |
|
| 151 | + throw new RequestInvalidSignatureException('Parse cert failed.'); |
|
| 152 | + } |
|
| 153 | 153 | |
| 154 | - return $certContent; |
|
| 155 | - } |
|
| 154 | + return $certContent; |
|
| 155 | + } |
|
| 156 | 156 | |
| 157 | - /** |
|
| 157 | + /** |
|
| 158 | 158 | * @throws OutdatedCertExceptionException |
| 159 | 159 | * @throws RequestInvalidSignatureException |
| 160 | 160 | */ |
| 161 | - private function validateCertContent(array $cert, string $localCertPath): void |
|
| 162 | - { |
|
| 163 | - $this->validateCertSubject($cert); |
|
| 164 | - $this->validateCertValidTime($cert, $localCertPath); |
|
| 165 | - } |
|
| 161 | + private function validateCertContent(array $cert, string $localCertPath): void |
|
| 162 | + { |
|
| 163 | + $this->validateCertSubject($cert); |
|
| 164 | + $this->validateCertValidTime($cert, $localCertPath); |
|
| 165 | + } |
|
| 166 | 166 | |
| 167 | - /** |
|
| 167 | + /** |
|
| 168 | 168 | * @throws RequestInvalidSignatureException |
| 169 | 169 | */ |
| 170 | - private function validateCertSubject(array $cert): void |
|
| 171 | - { |
|
| 172 | - if (false === isset($cert['extensions']['subjectAltName']) || |
|
| 173 | - false === stristr($cert['extensions']['subjectAltName'], 'echo-api.amazon.com') |
|
| 174 | - ) { |
|
| 175 | - throw new RequestInvalidSignatureException('Cert subject error.'); |
|
| 170 | + private function validateCertSubject(array $cert): void |
|
| 171 | + { |
|
| 172 | + if (false === isset($cert['extensions']['subjectAltName']) || |
|
| 173 | + false === stristr($cert['extensions']['subjectAltName'], 'echo-api.amazon.com') |
|
| 174 | + ) { |
|
| 175 | + throw new RequestInvalidSignatureException('Cert subject error.'); |
|
| 176 | + } |
|
| 176 | 177 | } |
| 177 | - } |
|
| 178 | 178 | |
| 179 | - /** |
|
| 179 | + /** |
|
| 180 | 180 | * @throws OutdatedCertExceptionException |
| 181 | 181 | */ |
| 182 | - private function validateCertValidTime(array $cert, string $localCertPath): void |
|
| 183 | - { |
|
| 184 | - if (false === isset($cert['validTo_time_t']) || time() > $cert['validTo_time_t'] || false === isset($cert['validFrom_time_t']) || time() < $cert['validFrom_time_t']) { |
|
| 185 | - if (file_exists($localCertPath)) { |
|
| 186 | - /* @scrutinizer ignore-unhandled */ @unlink($localCertPath); |
|
| 182 | + private function validateCertValidTime(array $cert, string $localCertPath): void |
|
| 183 | + { |
|
| 184 | + if (false === isset($cert['validTo_time_t']) || time() > $cert['validTo_time_t'] || false === isset($cert['validFrom_time_t']) || time() < $cert['validFrom_time_t']) { |
|
| 185 | + if (file_exists($localCertPath)) { |
|
| 186 | + /* @scrutinizer ignore-unhandled */ @unlink($localCertPath); |
|
| 187 | + } |
|
| 188 | + throw new OutdatedCertExceptionException('Cert is outdated.'); |
|
| 187 | 189 | } |
| 188 | - throw new OutdatedCertExceptionException('Cert is outdated.'); |
|
| 189 | 190 | } |
| 190 | - } |
|
| 191 | 191 | } |
@@ -7,7 +7,7 @@ |
||
| 7 | 7 | class Settings implements \JsonSerializable |
| 8 | 8 | { |
| 9 | 9 | public function __construct( |
| 10 | - public int|float|null $idleTimeout = null, |
|
| 10 | + public int | float | null $idleTimeout = null, |
|
| 11 | 11 | public ?PseudoLocalization $pseudoLocalization = null, |
| 12 | 12 | public bool $supportsResizing = false, |
| 13 | 13 | ) { |
@@ -1,32 +1,32 @@ |
||
| 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 Settings implements \JsonSerializable |
|
| 8 | -{ |
|
| 9 | - public function __construct( |
|
| 10 | - public int|float|null $idleTimeout = null, |
|
| 11 | - public ?PseudoLocalization $pseudoLocalization = null, |
|
| 12 | - public bool $supportsResizing = false, |
|
| 13 | - ) { |
|
| 14 | - } |
|
| 15 | - |
|
| 16 | - public function jsonSerialize(): array |
|
| 7 | + class Settings implements \JsonSerializable |
|
| 17 | 8 | { |
| 18 | - $data = []; |
|
| 19 | - |
|
| 20 | - if ($this->idleTimeout !== null) { |
|
| 21 | - $data['idleTimeout'] = $this->idleTimeout; |
|
| 22 | - } |
|
| 23 | - if ($this->pseudoLocalization !== null) { |
|
| 24 | - $data['pseudoLocalization'] = $this->pseudoLocalization; |
|
| 25 | - } |
|
| 26 | - if ($this->supportsResizing) { |
|
| 27 | - $data['supportsResizing'] = $this->supportsResizing; |
|
| 9 | + public function __construct( |
|
| 10 | + public int|float|null $idleTimeout = null, |
|
| 11 | + public ?PseudoLocalization $pseudoLocalization = null, |
|
| 12 | + public bool $supportsResizing = false, |
|
| 13 | + ) { |
|
| 28 | 14 | } |
| 29 | 15 | |
| 30 | - return $data; |
|
| 31 | - } |
|
| 16 | + public function jsonSerialize(): array |
|
| 17 | + { |
|
| 18 | + $data = []; |
|
| 19 | + |
|
| 20 | + if ($this->idleTimeout !== null) { |
|
| 21 | + $data['idleTimeout'] = $this->idleTimeout; |
|
| 22 | + } |
|
| 23 | + if ($this->pseudoLocalization !== null) { |
|
| 24 | + $data['pseudoLocalization'] = $this->pseudoLocalization; |
|
| 25 | + } |
|
| 26 | + if ($this->supportsResizing) { |
|
| 27 | + $data['supportsResizing'] = $this->supportsResizing; |
|
| 28 | + } |
|
| 29 | + |
|
| 30 | + return $data; |
|
| 31 | + } |
|
| 32 | 32 | } |
@@ -29,9 +29,9 @@ |
||
| 29 | 29 | case SPINBUTTON = 'spinbutton'; |
| 30 | 30 | case SUMMARY = 'summary'; |
| 31 | 31 | case SWITCH = 'switch'; |
| 32 | - case TAB = 'tab'; |
|
| 33 | - case TABLIST = 'tablist'; |
|
| 34 | - case TEXT = 'text'; |
|
| 35 | - case TIMER = 'timer'; |
|
| 36 | - case TOOLBAR = 'toolbar'; |
|
| 32 | + case TAB = 'tab'; |
|
| 33 | + case TABLIST = 'tablist'; |
|
| 34 | + case TEXT = 'text'; |
|
| 35 | + case TIMER = 'timer'; |
|
| 36 | + case TOOLBAR = 'toolbar'; |
|
| 37 | 37 | } |
@@ -1,12 +1,12 @@ |
||
| 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 SwipeAction: string |
|
| 8 | -{ |
|
| 9 | - case REVEAL = 'reveal'; |
|
| 10 | - case SLIDE = 'slide'; |
|
| 11 | - case COVER = 'cover'; |
|
| 7 | + enum SwipeAction: string |
|
| 8 | + { |
|
| 9 | + case REVEAL = 'reveal'; |
|
| 10 | + case SLIDE = 'slide'; |
|
| 11 | + case COVER = 'cover'; |
|
| 12 | 12 | } |
@@ -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\Document; |
|
| 5 | + namespace MaxBeckers\AmazonAlexa\Response\Directives\APL\Document; |
|
| 6 | 6 | |
| 7 | -class Value implements \JsonSerializable |
|
| 8 | -{ |
|
| 9 | - /** |
|
| 7 | + class Value implements \JsonSerializable |
|
| 8 | + { |
|
| 9 | + /** |
|
| 10 | 10 | * @param string $property The property to animate |
| 11 | 11 | * @param int|float $to Target value for the animation |
| 12 | 12 | * @param int|float|null $from Starting value (optional). Null means: use current runtime value as implicit start. |
| 13 | 13 | */ |
| 14 | - public function __construct( |
|
| 15 | - public string $property, |
|
| 16 | - public int|float $to, |
|
| 17 | - public int|float|null $from = null, |
|
| 18 | - ) { |
|
| 19 | - } |
|
| 14 | + public function __construct( |
|
| 15 | + public string $property, |
|
| 16 | + public int|float $to, |
|
| 17 | + public int|float|null $from = null, |
|
| 18 | + ) { |
|
| 19 | + } |
|
| 20 | 20 | |
| 21 | - public function jsonSerialize(): array |
|
| 22 | - { |
|
| 23 | - $out = [ |
|
| 24 | - 'property' => $this->property, |
|
| 25 | - ]; |
|
| 21 | + public function jsonSerialize(): array |
|
| 22 | + { |
|
| 23 | + $out = [ |
|
| 24 | + 'property' => $this->property, |
|
| 25 | + ]; |
|
| 26 | 26 | |
| 27 | - if ($this->from !== null) { |
|
| 28 | - $out['from'] = $this->from; |
|
| 29 | - } |
|
| 27 | + if ($this->from !== null) { |
|
| 28 | + $out['from'] = $this->from; |
|
| 29 | + } |
|
| 30 | 30 | |
| 31 | - $out['to'] = $this->to; |
|
| 31 | + $out['to'] = $this->to; |
|
| 32 | 32 | |
| 33 | - return $out; |
|
| 34 | - } |
|
| 33 | + return $out; |
|
| 34 | + } |
|
| 35 | 35 | } |
@@ -13,8 +13,8 @@ |
||
| 13 | 13 | */ |
| 14 | 14 | public function __construct( |
| 15 | 15 | public string $property, |
| 16 | - public int|float $to, |
|
| 17 | - public int|float|null $from = null, |
|
| 16 | + public int | float $to, |
|
| 17 | + public int | float | null $from = null, |
|
| 18 | 18 | ) { |
| 19 | 19 | } |
| 20 | 20 | |
@@ -1,12 +1,12 @@ 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\Document; |
|
| 5 | + namespace MaxBeckers\AmazonAlexa\Response\Directives\APL\Document; |
|
| 6 | 6 | |
| 7 | -class Import implements \JsonSerializable |
|
| 8 | -{ |
|
| 9 | - /** |
|
| 7 | + class Import implements \JsonSerializable |
|
| 8 | + { |
|
| 9 | + /** |
|
| 10 | 10 | * @param string $name Package name property |
| 11 | 11 | * @param string $version Package version property |
| 12 | 12 | * @param string|null $accept Package accept property (APL 2024.3 and later) |
@@ -15,40 +15,40 @@ discard block |
||
| 15 | 15 | * @param ImportType|null $type Polymorphic type property |
| 16 | 16 | * @param bool $when When false, ignore this import |
| 17 | 17 | */ |
| 18 | - public function __construct( |
|
| 19 | - public string $name, |
|
| 20 | - public string $version, |
|
| 21 | - public ?string $accept = null, |
|
| 22 | - public ?array $loadAfter = null, |
|
| 23 | - public ?string $source = null, |
|
| 24 | - public ?ImportType $type = null, |
|
| 25 | - public bool $when = true, |
|
| 26 | - ) { |
|
| 27 | - } |
|
| 18 | + public function __construct( |
|
| 19 | + public string $name, |
|
| 20 | + public string $version, |
|
| 21 | + public ?string $accept = null, |
|
| 22 | + public ?array $loadAfter = null, |
|
| 23 | + public ?string $source = null, |
|
| 24 | + public ?ImportType $type = null, |
|
| 25 | + public bool $when = true, |
|
| 26 | + ) { |
|
| 27 | + } |
|
| 28 | 28 | |
| 29 | - public function jsonSerialize(): array |
|
| 30 | - { |
|
| 31 | - $data = [ |
|
| 32 | - 'name' => $this->name, |
|
| 33 | - 'version' => $this->version, |
|
| 34 | - ]; |
|
| 29 | + public function jsonSerialize(): array |
|
| 30 | + { |
|
| 31 | + $data = [ |
|
| 32 | + 'name' => $this->name, |
|
| 33 | + 'version' => $this->version, |
|
| 34 | + ]; |
|
| 35 | 35 | |
| 36 | - if ($this->accept !== null && $this->accept !== '') { |
|
| 37 | - $data['accept'] = $this->accept; |
|
| 38 | - } |
|
| 39 | - if ($this->loadAfter !== null && $this->loadAfter !== []) { |
|
| 40 | - $data['loadAfter'] = $this->loadAfter; |
|
| 41 | - } |
|
| 42 | - if ($this->source !== null && $this->source !== '') { |
|
| 43 | - $data['source'] = $this->source; |
|
| 44 | - } |
|
| 45 | - if ($this->type !== null) { |
|
| 46 | - $data['type'] = $this->type->value; |
|
| 47 | - } |
|
| 48 | - if (!$this->when) { |
|
| 49 | - $data['when'] = $this->when; |
|
| 50 | - } |
|
| 36 | + if ($this->accept !== null && $this->accept !== '') { |
|
| 37 | + $data['accept'] = $this->accept; |
|
| 38 | + } |
|
| 39 | + if ($this->loadAfter !== null && $this->loadAfter !== []) { |
|
| 40 | + $data['loadAfter'] = $this->loadAfter; |
|
| 41 | + } |
|
| 42 | + if ($this->source !== null && $this->source !== '') { |
|
| 43 | + $data['source'] = $this->source; |
|
| 44 | + } |
|
| 45 | + if ($this->type !== null) { |
|
| 46 | + $data['type'] = $this->type->value; |
|
| 47 | + } |
|
| 48 | + if (!$this->when) { |
|
| 49 | + $data['when'] = $this->when; |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - return $data; |
|
| 53 | - } |
|
| 52 | + return $data; |
|
| 53 | + } |
|
| 54 | 54 | } |
@@ -1,14 +1,14 @@ |
||
| 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 AlignItems: string |
|
| 8 | -{ |
|
| 9 | - case STRETCH = 'stretch'; |
|
| 10 | - case CENTER = 'center'; |
|
| 11 | - case START = 'start'; |
|
| 12 | - case END = 'end'; |
|
| 13 | - case BASELINE = 'baseline'; |
|
| 7 | + enum AlignItems: string |
|
| 8 | + { |
|
| 9 | + case STRETCH = 'stretch'; |
|
| 10 | + case CENTER = 'center'; |
|
| 11 | + case START = 'start'; |
|
| 12 | + case END = 'end'; |
|
| 13 | + case BASELINE = 'baseline'; |
|
| 14 | 14 | } |
@@ -1,14 +1,14 @@ |
||
| 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 Scale: string |
|
| 8 | -{ |
|
| 9 | - case BEST_FIT = 'best-fit'; |
|
| 10 | - case BEST_FILL = 'best-fill'; |
|
| 11 | - case BEST_FIT_DOWN = 'best-fit-down'; |
|
| 12 | - case FILL = 'fill'; |
|
| 13 | - case NONE = 'none'; |
|
| 7 | + enum Scale: string |
|
| 8 | + { |
|
| 9 | + case BEST_FIT = 'best-fit'; |
|
| 10 | + case BEST_FILL = 'best-fill'; |
|
| 11 | + case BEST_FIT_DOWN = 'best-fit-down'; |
|
| 12 | + case FILL = 'fill'; |
|
| 13 | + case NONE = 'none'; |
|
| 14 | 14 | } |
@@ -1,14 +1,14 @@ |
||
| 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 SubmitKeyType: string |
|
| 8 | -{ |
|
| 9 | - case DONE = 'done'; |
|
| 10 | - case GO = 'go'; |
|
| 11 | - case NEXT = 'next'; |
|
| 12 | - case SEARCH = 'search'; |
|
| 13 | - case SEND = 'send'; |
|
| 7 | + enum SubmitKeyType: string |
|
| 8 | + { |
|
| 9 | + case DONE = 'done'; |
|
| 10 | + case GO = 'go'; |
|
| 11 | + case NEXT = 'next'; |
|
| 12 | + case SEARCH = 'search'; |
|
| 13 | + case SEND = 'send'; |
|
| 14 | 14 | } |