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
|
|
|
public ?string $url = null; |
20
|
|
|
public ?string $size = null; |
21
|
|
|
public ?int $widthPixels = null; |
22
|
|
|
public ?int $heightPixels = null; |
23
|
|
|
|
24
|
3 |
|
public static function create(string $url, ?string $size = null, ?int $widthPixels = null, ?int $heightPixels = null): self |
25
|
|
|
{ |
26
|
3 |
|
$imageSource = new self(); |
27
|
|
|
|
28
|
3 |
|
$imageSource->url = $url; |
29
|
3 |
|
$imageSource->size = $size; |
30
|
3 |
|
$imageSource->widthPixels = $widthPixels; |
31
|
3 |
|
$imageSource->heightPixels = $heightPixels; |
32
|
|
|
|
33
|
3 |
|
return $imageSource; |
34
|
|
|
} |
35
|
|
|
|
36
|
2 |
|
public function jsonSerialize(): \ArrayObject |
37
|
|
|
{ |
38
|
2 |
|
$data = new \ArrayObject(); |
39
|
|
|
|
40
|
2 |
|
$this->valueToArrayIfSet($data, 'url'); |
41
|
2 |
|
$this->valueToArrayIfSet($data, 'size'); |
42
|
2 |
|
$this->valueToArrayIfSet($data, 'widthPixels'); |
43
|
2 |
|
$this->valueToArrayIfSet($data, 'heightPixels'); |
44
|
|
|
|
45
|
2 |
|
return $data; |
46
|
|
|
} |
47
|
|
|
} |
48
|
|
|
|