1 | <?php |
||
11 | class MediaElement implements \JsonSerializable |
||
12 | { |
||
13 | use ValidatorTrait; |
||
14 | |||
15 | public const TYPE_IMAGE = 'image'; |
||
16 | public const TYPE_VIDEO = 'video'; |
||
17 | |||
18 | /** |
||
19 | * @var string |
||
20 | */ |
||
21 | protected $mediaType; |
||
22 | |||
23 | /** |
||
24 | * @var string|null |
||
25 | */ |
||
26 | protected $attachmentId; |
||
27 | |||
28 | /** |
||
29 | * @var string|null |
||
30 | */ |
||
31 | protected $url; |
||
32 | |||
33 | /** |
||
34 | * @var \Kerox\Messenger\Model\Common\Button\AbstractButton[]|null |
||
35 | */ |
||
36 | protected $buttons; |
||
37 | |||
38 | /** |
||
39 | * MediaElement constructor. |
||
40 | * |
||
41 | * @throws \Kerox\Messenger\Exception\MessengerException |
||
42 | */ |
||
43 | 3 | public function __construct(string $url, string $mediaType = self::TYPE_IMAGE) |
|
55 | |||
56 | /** |
||
57 | * @throws \Kerox\Messenger\Exception\MessengerException |
||
58 | * |
||
59 | * @return \Kerox\Messenger\Model\Message\Attachment\Template\Element\MediaElement |
||
60 | */ |
||
61 | 3 | public static function create(string $url, string $mediaType = self::TYPE_IMAGE): self |
|
65 | |||
66 | /** |
||
67 | * @param \Kerox\Messenger\Model\Common\Button\AbstractButton[] $buttons |
||
68 | * |
||
69 | * @throws \Kerox\Messenger\Exception\MessengerException |
||
70 | * |
||
71 | * @return \Kerox\Messenger\Model\Message\Attachment\Template\Element\MediaElement |
||
72 | */ |
||
73 | 2 | public function setButtons(array $buttons): self |
|
82 | |||
83 | 2 | protected function getAllowedButtonsType(): array |
|
89 | |||
90 | 3 | private function isAttachmentId(string $value): bool |
|
94 | |||
95 | /** |
||
96 | * @throws \Kerox\Messenger\Exception\MessengerException |
||
97 | */ |
||
98 | 3 | private function isValidMediaType(string $mediaType): void |
|
105 | |||
106 | 3 | protected function getAllowedMediaType(): array |
|
113 | |||
114 | 1 | public function toArray(): array |
|
125 | |||
126 | 1 | public function jsonSerialize(): array |
|
130 | } |
||
131 |