|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace MaxBeckers\AmazonAlexa\Response\Directives\Display; |
|
6
|
|
|
|
|
7
|
|
|
use MaxBeckers\AmazonAlexa\Helper\SerializeValueMapper; |
|
8
|
|
|
|
|
9
|
|
|
class ImageSource implements \JsonSerializable |
|
10
|
|
|
{ |
|
11
|
|
|
use SerializeValueMapper; |
|
12
|
|
|
|
|
13
|
|
|
public const SIZE_X_SMALL = 'X_SMALL'; |
|
14
|
|
|
public const SIZE_SMALL = 'SMALL'; |
|
15
|
|
|
public const SIZE_MEDIUM = 'MEDIUM'; |
|
16
|
|
|
public const SIZE_LARGE = 'LARGE'; |
|
17
|
|
|
public const SIZE_X_LARGE = 'X_LARGE'; |
|
18
|
|
|
|
|
19
|
3 |
|
public function __construct( |
|
20
|
|
|
public ?string $url = null, |
|
21
|
|
|
public ?string $size = null, |
|
22
|
|
|
public ?int $widthPixels = null, |
|
23
|
|
|
public ?int $heightPixels = null |
|
24
|
|
|
) { |
|
25
|
3 |
|
} |
|
26
|
|
|
|
|
27
|
3 |
|
public static function create(string $url, ?string $size = null, ?int $widthPixels = null, ?int $heightPixels = null): self |
|
28
|
|
|
{ |
|
29
|
3 |
|
return new self($url, $size, $widthPixels, $heightPixels); |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
2 |
|
public function jsonSerialize(): \ArrayObject |
|
33
|
|
|
{ |
|
34
|
2 |
|
$data = new \ArrayObject(); |
|
35
|
|
|
|
|
36
|
2 |
|
$this->valueToArrayIfSet($data, 'url'); |
|
37
|
2 |
|
$this->valueToArrayIfSet($data, 'size'); |
|
38
|
2 |
|
$this->valueToArrayIfSet($data, 'widthPixels'); |
|
39
|
2 |
|
$this->valueToArrayIfSet($data, 'heightPixels'); |
|
40
|
|
|
|
|
41
|
2 |
|
return $data; |
|
42
|
|
|
} |
|
43
|
|
|
} |
|
44
|
|
|
|