Add constructors and setters to InputMedia classes

This commit is contained in:
netkas 2024-10-09 20:57:04 -04:00
parent 19b4d2ef45
commit 427102a635
5 changed files with 739 additions and 42 deletions

View file

@ -24,6 +24,22 @@
private ?int $duration;
private bool $has_spoiler;
/**
* InputMediaAnimation constructor.
*/
public function __construct()
{
$this->media = (string)null;
$this->thumb = null;
$this->caption = null;
$this->parse_mode = null;
$this->caption_entities = null;
$this->width = null;
$this->height = null;
$this->duration = null;
$this->has_spoiler = false;
}
/**
* File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP
* URL for Telegram to get a file from the Internet, or pass “attach://<file_attach_name> to upload a new one
@ -37,6 +53,21 @@
return $this->media;
}
/**
* Sets the file to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP
* URL for Telegram to get a file from the Internet, or pass “attach://<file_attach_name> to upload a new one
* using multipart/form-data under <file_attach_name> name.
*
* @see https://core.telegram.org/bots/api#sending-files
* @param string $media
* @return InputMediaAnimation
*/
public function setMedia(string $media): InputMediaAnimation
{
$this->media = $media;
return $this;
}
/**
* Optional. Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported
* server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail's width and
@ -52,6 +83,23 @@
return $this->thumb;
}
/**
* Optional. Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported
* server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail's width and
* height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can't
* be reused and can be only uploaded as a new file, so you can pass “attach://<file_attach_name> if the
* thumbnail was uploaded using multipart/form-data under <file_attach_name>.
*
* @see https://core.telegram.org/bots/api#sending-files
* @param string|null $thumb
* @return InputMediaAnimation
*/
public function setThumb(?string $thumb): InputMediaAnimation
{
$this->thumb = $thumb;
return $this;
}
/**
* Optional. Caption of the animation to be sent, 0-1024 characters after entities parsing
*
@ -63,6 +111,19 @@
return $this->caption;
}
/**
* Optional. Caption of the animation to be sent, 0-1024 characters after entities parsing
*
* @see https://core.telegram.org/bots/api#sending-files
* @param string|null $caption
* @return InputMediaAnimation
*/
public function setCaption(?string $caption): InputMediaAnimation
{
$this->caption = $caption;
return $this;
}
/**
* Optional. Mode for parsing entities in the animation caption.
*
@ -74,6 +135,19 @@
return $this->parse_mode;
}
/**
* Optional. Mode for parsing entities in the animation caption.
*
* @see https://core.telegram.org/bots/api#formatting-options
* @param ParseMode|null $parse_mode
* @return InputMediaAnimation
*/
public function setParseMode(?ParseMode $parse_mode): InputMediaAnimation
{
$this->parse_mode = $parse_mode;
return $this;
}
/**
* Optional. List of special entities that appear in the caption, which can be specified instead of parse_mode
*
@ -84,6 +158,18 @@
return $this->caption_entities;
}
/**
* Optional. List of special entities that appear in the caption, which can be specified instead of parse_mode
*
* @param MessageEntity[]|null $caption_entities
* @return InputMediaAnimation
*/
public function setCaptionEntities(?array $caption_entities): InputMediaAnimation
{
$this->caption_entities = $caption_entities;
return $this;
}
/**
* Optional. Animation width
*
@ -94,6 +180,18 @@
return $this->width;
}
/**
* Optional. Animation width
*
* @param int|null $width
* @return InputMediaAnimation
*/
public function setWidth(?int $width): InputMediaAnimation
{
$this->width = $width;
return $this;
}
/**
* Optional. Animation height
*
@ -104,6 +202,18 @@
return $this->height;
}
/**
* Optional. Animation height
*
* @param int|null $height
* @return InputMediaAnimation
*/
public function setHeight(?int $height): InputMediaAnimation
{
$this->height = $height;
return $this;
}
/**
* Optional. Animation duration in seconds
*
@ -114,6 +224,18 @@
return $this->duration;
}
/**
* Optional. Animation duration in seconds
*
* @param int|null $duration
* @return InputMediaAnimation
*/
public function setDuration(?int $duration): InputMediaAnimation
{
$this->duration = $duration;
return $this;
}
/**
* Optional. Pass True if the animation needs to be covered with a spoiler animation
*
@ -124,23 +246,69 @@
return $this->has_spoiler;
}
/**
* Optional. Pass True if the animation needs to be covered with a spoiler animation
*
* @param bool $has_spoiler
* @return InputMediaAnimation
*/
public function setHasSpoiler(bool $has_spoiler): InputMediaAnimation
{
$this->has_spoiler = $has_spoiler;
return $this;
}
/**
* @inheritDoc
*/
public function toArray(): array
{
return [
$array = [
'type' => $this->type->value,
'media' => $this->media,
'thumb' => $this->thumb,
'caption' => $this->caption,
'parse_mode' => $this->parse_mode->value,
'caption_entities' => array_map(fn(MessageEntity $item) => $item->toArray(), $this->caption_entities),
'width' => $this->width,
'height' => $this->height,
'duration' => $this->duration,
'has_spoiler' => $this->has_spoiler,
];
if($this->thumb !== null)
{
$array['thumb'] = $this->thumb;
}
if($this->caption !== null)
{
$array['caption'] = $this->caption;
}
if($this->parse_mode !== null)
{
$array['parse_mode'] = $this->parse_mode->value;
}
if($this->caption_entities !== null)
{
$array['caption_entities'] = array_map(fn(MessageEntity $entity) => $entity->toArray(), $this->caption_entities);
}
if($this->width !== null)
{
$array['width'] = $this->width;
}
if($this->height !== null)
{
$array['height'] = $this->height;
}
if($this->duration !== null)
{
$array['duration'] = $this->duration;
}
if($this->has_spoiler)
{
$array['has_spoiler'] = $this->has_spoiler;
}
return $array;
}
/**

View file

@ -22,6 +22,21 @@
private ?string $performer;
private ?string $title;
/**
* InputMediaAudio constructor.
*/
public function __construct()
{
$this->media = (string)null;
$this->thumb = null;
$this->caption = null;
$this->parse_mode = null;
$this->caption_entities = null;
$this->duration = null;
$this->performer = null;
$this->title = null;
}
/**
* File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP
* URL for Telegram to get a file from the Internet, or pass “attach://<file_attach_name> to upload a new one
@ -35,6 +50,21 @@
return $this->media;
}
/**
* Sets the file to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP
* URL for Telegram to get a file from the Internet, or pass “attach://<file_attach_name> to upload a new one
* using multipart/form-data under <file_attach_name> name.
*
* @see https://core.telegram.org/bots/api#sending-files
* @param string $media
* @return InputMediaAudio
*/
public function setMedia(string $media): InputMediaAudio
{
$this->media = $media;
return $this;
}
/**
* Optional. Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported
* server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail's width and
@ -50,6 +80,23 @@
return $this->thumb;
}
/**
* Optional. Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported
* server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail's width and
* height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can't
* be reused and can be only uploaded as a new file, so you can pass “attach://<file_attach_name> if the
* thumbnail was uploaded using multipart/form-data under <file_attach_name>.
*
* @see https://core.telegram.org/bots/api#sending-files
* @param string|null $thumb
* @return InputMediaAudio
*/
public function setThumb(?string $thumb): InputMediaAudio
{
$this->thumb = $thumb;
return $this;
}
/**
* Optional. Caption of the audio to be sent, 0-1024 characters after entities parsing
*
@ -60,6 +107,18 @@
return $this->caption;
}
/**
* Optional. Caption of the audio to be sent, 0-1024 characters after entities parsing
*
* @param string|null $caption
* @return InputMediaAudio
*/
public function setCaption(?string $caption): InputMediaAudio
{
$this->caption = $caption;
return $this;
}
/**
* Optional. Mode for parsing entities in the audio caption.
*
@ -70,6 +129,18 @@
return $this->parse_mode;
}
/**
* Optional. Mode for parsing entities in the audio caption.
*
* @param ParseMode|null $parse_mode
* @return InputMediaAudio
*/
public function setParseMode(?ParseMode $parse_mode): InputMediaAudio
{
$this->parse_mode = $parse_mode;
return $this;
}
/**
* Optional. List of special entities that appear in the caption, which can be specified instead of parse_mode
*
@ -80,6 +151,18 @@
return $this->caption_entities;
}
/**
* Optional. List of special entities that appear in the caption, which can be specified instead of parse_mode
*
* @param MessageEntity[]|null $caption_entities
* @return InputMediaAudio
*/
public function setCaptionEntities(?array $caption_entities): InputMediaAudio
{
$this->caption_entities = $caption_entities;
return $this;
}
/**
* Optional. Duration of the audio in seconds
*
@ -90,6 +173,18 @@
return $this->duration;
}
/**
* Optional. Duration of the audio in seconds
*
* @param int|null $duration
* @return InputMediaAudio
*/
public function setDuration(?int $duration): InputMediaAudio
{
$this->duration = $duration;
return $this;
}
/**
* Optional. Performer of the audio
*
@ -100,6 +195,18 @@
return $this->performer;
}
/**
* Optional. Performer of the audio
*
* @param string|null $performer
* @return InputMediaAudio
*/
public function setPerformer(?string $performer): InputMediaAudio
{
$this->performer = $performer;
return $this;
}
/**
* Optional. Title of the audio
*
@ -110,22 +217,64 @@
return $this->title;
}
/**
* Optional. Title of the audio
*
* @param string|null $title
* @return InputMediaAudio
*/
public function setTitle(?string $title): InputMediaAudio
{
$this->title = $title;
return $this;
}
/**
* @inheritDoc
*/
public function toArray(): array
{
return [
$array = [
'type' => $this->type?->value,
'media' => $this->media,
'thumb' => $this->thumb,
'caption' => $this->caption,
'parse_mode' => $this->parse_mode->value,
'caption_entities' => is_null($this->caption_entities) ? null : array_map(fn(MessageEntity $item) => $item->toArray(), $this->caption_entities),
'duration' => $this->duration,
'performer' => $this->performer,
'title' => $this->title
];
if($this->thumb !== null)
{
$array['thumb'] = $this->thumb;
}
if($this->caption !== null)
{
$array['caption'] = $this->caption;
}
if($this->parse_mode !== null)
{
$array['parse_mode'] = $this->parse_mode->value;
}
if($this->caption_entities !== null)
{
$array['caption_entities'] = array_map(fn(MessageEntity $entity) => $entity->toArray(), $this->caption_entities);
}
if($this->duration !== null)
{
$array['duration'] = $this->duration;
}
if($this->performer !== null)
{
$array['performer'] = $this->performer;
}
if($this->title !== null)
{
$array['title'] = $this->title;
}
return $array;
}
/**

View file

@ -20,6 +20,19 @@
private ?array $caption_entities;
private bool $disable_content_type_detection;
/**
* InputMediaDocument constructor.
*/
public function __construct()
{
$this->media = (string)null;
$this->thumb = null;
$this->caption = null;
$this->parse_mode = null;
$this->caption_entities = null;
$this->disable_content_type_detection = false;
}
/**
* File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP
* URL for Telegram to get a file from the Internet, or pass “attach://<file_attach_name> to upload a new one
@ -33,6 +46,21 @@
return $this->media;
}
/**
* Sets the file to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP
* URL for Telegram to get a file from the Internet, or pass “attach://<file_attach_name> to upload a new one
* using multipart/form-data under <file_attach_name> name.
*
* @see https://core.telegram.org/bots/api#sending-files
* @param string $media
* @return InputMediaDocument
*/
public function setMedia(string $media): InputMediaDocument
{
$this->media = $media;
return $this;
}
/**
* Optional. Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported
* server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail's width and
@ -48,6 +76,23 @@
return $this->thumb;
}
/**
* Optional. Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported
* server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail's width and
* height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can't
* be reused and can be only uploaded as a new file, so you can pass “attach://<file_attach_name> if the
* thumbnail was uploaded using multipart/form-data under <file_attach_name>.
*
* @see https://core.telegram.org/bots/api#sending-files
* @param string|null $thumb
* @return InputMediaDocument
*/
public function setThumb(?string $thumb): InputMediaDocument
{
$this->thumb = $thumb;
return $this;
}
/**
* Optional. Caption of the document to be sent, 0-1024 characters after entities parsing
*
@ -58,6 +103,18 @@
return $this->caption;
}
/**
* Optional. Caption of the document to be sent, 0-1024 characters after entities parsing
*
* @param string|null $caption
* @return InputMediaDocument
*/
public function setCaption(?string $caption): InputMediaDocument
{
$this->caption = $caption;
return $this;
}
/**
* Optional. Mode for parsing entities in the document caption.
*
@ -69,6 +126,19 @@
return $this->parse_mode;
}
/**
* Optional. Mode for parsing entities in the document caption.
*
* @see https://core.telegram.org/bots/api#formatting-options
* @param ParseMode|null $parse_mode
* @return InputMediaDocument
*/
public function setParseMode(?ParseMode $parse_mode): InputMediaDocument
{
$this->parse_mode = $parse_mode;
return $this;
}
/**
* Optional. List of special entities that appear in the caption, which can be specified instead of parse_mode
*
@ -79,6 +149,18 @@
return $this->caption_entities;
}
/**
* Optional. List of special entities that appear in the caption, which can be specified instead of parse_mode
*
* @param MessageEntity[]|null $caption_entities
* @return InputMediaDocument
*/
public function setCaptionEntities(?array $caption_entities): InputMediaDocument
{
$this->caption_entities = $caption_entities;
return $this;
}
/**
* Optional. Disables automatic server-side content type detection for files uploaded using multipart/form-data.
* Always True, if the document is sent as part of an album.
@ -90,20 +172,55 @@
return $this->disable_content_type_detection;
}
/**
* Optional. Disables automatic server-side content type detection for files uploaded using multipart/form-data.
* Always True, if the document is sent as part of an album.
*
* @param bool $disable_content_type_detection
* @return InputMediaDocument
*/
public function setDisableContentTypeDetection(bool $disable_content_type_detection): InputMediaDocument
{
$this->disable_content_type_detection = $disable_content_type_detection;
return $this;
}
/**
* @inheritDoc
*/
public function toArray(): array
{
return [
$array = [
'type' => $this->type->value,
'media' => $this->media,
'thumb' => $this->thumb,
'caption' => $this->caption,
'parse_mode' => $this->parse_mode->value,
'caption_entities' => array_map(fn(MessageEntity $item) => $item->toArray(), $this->caption_entities),
'disable_content_type_detection' => $this->disable_content_type_detection,
'media' => $this->media
];
if($this->thumb !== null)
{
$array['thumb'] = $this->thumb;
}
if($this->caption !== null)
{
$array['caption'] = $this->caption;
}
if($this->parse_mode !== null)
{
$array['parse_mode'] = $this->parse_mode->value;
}
if($this->caption_entities !== null)
{
$array['caption_entities'] = array_map(fn(MessageEntity $entity) => $entity->toArray(), $this->caption_entities);
}
if($this->disable_content_type_detection)
{
$array['disable_content_type_detection'] = $this->disable_content_type_detection;
}
return $array;
}
/**

View file

@ -19,6 +19,18 @@
private ?array $caption_entities;
private bool $has_spoiler;
/**
* InputMediaPhoto constructor.
*/
public function __construct()
{
$this->media = '';
$this->caption = null;
$this->parse_mode = null;
$this->caption_entities = null;
$this->has_spoiler = false;
}
/**
* File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP
* URL for Telegram to get a file from the Internet, or pass “attach://<file_attach_name> to upload a new one
@ -32,6 +44,21 @@
return $this->media;
}
/**
* Sets the file to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP
* URL for Telegram to get a file from the Internet, or pass “attach://<file_attach_name> to upload a new one
* using multipart/form-data under <file_attach_name> name.
*
* @see https://core.telegram.org/bots/api#sending-files
* @param string $media
* @return InputMediaPhoto
*/
public function setMedia(string $media): InputMediaPhoto
{
$this->media = $media;
return $this;
}
/**
* Optional. Caption of the photo to be sent, 0-1024 characters after entities parsing
*
@ -42,6 +69,18 @@
return $this->caption;
}
/**
* Sets the caption of the photo to be sent, 0-1024 characters after entities parsing
*
* @param string|null $caption
* @return InputMediaPhoto
*/
public function setCaption(?string $caption): InputMediaPhoto
{
$this->caption = $caption;
return $this;
}
/**
* Optional. Mode for parsing entities in the photo caption.
*
@ -53,6 +92,19 @@
return $this->parse_mode;
}
/**
* Sets the mode for parsing entities in the photo caption.
*
* @see https://core.telegram.org/bots/api#formatting-options
* @param ParseMode|null $parse_mode
* @return InputMediaPhoto
*/
public function setParseMode(?ParseMode $parse_mode): InputMediaPhoto
{
$this->parse_mode = $parse_mode;
return $this;
}
/**
* Optional. List of special entities that appear in the caption, which can be specified instead of parse_mode
*
@ -63,6 +115,18 @@
return $this->caption_entities;
}
/**
* Sets the list of special entities that appear in the caption, which can be specified instead of parse_mode
*
* @param array|null $caption_entities
* @return InputMediaPhoto
*/
public function setCaptionEntities(?array $caption_entities): InputMediaPhoto
{
$this->caption_entities = $caption_entities;
return $this;
}
/**
* Optional. Pass True if the photo needs to be covered with a spoiler animation
*
@ -73,6 +137,18 @@
return $this->has_spoiler;
}
/**
* Sets the photo needs to be covered with a spoiler animation
*
* @param bool $has_spoiler
* @return InputMediaPhoto
*/
public function setHasSpoiler(bool $has_spoiler): InputMediaPhoto
{
$this->has_spoiler = $has_spoiler;
return $this;
}
/**
* Returns an array representation of the object.
*
@ -80,14 +156,32 @@
*/
public function toArray(): array
{
return [
$array = [
'type' => $this->type->value,
'media' => $this->media,
'caption' => $this->caption,
'parse_mode' => $this->parse_mode->value,
'caption_entities' => array_map(fn(MessageEntity $item) => $item->toArray(), $this->caption_entities),
'has_spoiler' => $this->has_spoiler,
];
if($this->caption !== null)
{
$array['caption'] = $this->caption;
}
if($this->parse_mode !== null)
{
$array['parse_mode'] = $this->parse_mode->value;
}
if ($this->has_spoiler)
{
$array['has_spoiler'] = $this->has_spoiler;
}
if ($this->caption_entities !== null)
{
$array['caption_entities'] = array_map(fn(MessageEntity $entity) => $entity->toArray(), $this->caption_entities);
}
return $array;
}
/**

View file

@ -24,6 +24,23 @@
private bool $supports_streaming;
private bool $has_spoiler;
/**
* InputMediaVideo constructor.
*/
public function __construct()
{
$this->media = (string)null;
$this->thumb = null;
$this->caption = null;
$this->parse_mode = null;
$this->caption_entities = null;
$this->width = null;
$this->height = null;
$this->duration = null;
$this->supports_streaming = false;
$this->has_spoiler = false;
}
/**
* File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP
* URL for Telegram to get a file from the Internet, or pass “attach://<file_attach_name> to upload a new one
@ -52,6 +69,20 @@
return $this->thumb;
}
/**
* Sets the file to send. Pass a file_id to send a file that exists on the Telegram servers (recommended),
* pass an HTTP URL for Telegram to get a file from the Internet, or pass “attach://<file_attach_name> to upload
* a new one using multipart/form-data under <file_attach_name> name.
*
* @param string|null $thumb
* @return $this
*/
public function setThumb(?string $thumb): InputMediaVideo
{
$this->thumb = $thumb;
return $this;
}
/**
* Optional. Caption of the video to be sent, 0-1024 characters after entities parsing
*
@ -62,6 +93,18 @@
return $this->caption;
}
/**
* Sets the caption of the video to be sent, 0-1024 characters after entities parsing
*
* @param string|null $caption
* @return $this
*/
public function setCaption(?string $caption): InputMediaVideo
{
$this->caption = $caption;
return $this;
}
/**
* Optional. Mode for parsing entities in the video caption.
*
@ -73,6 +116,18 @@
return $this->parse_mode;
}
/**
* Sets the mode for parsing entities in the video caption.
*
* @param ParseMode|null $parse_mode
* @return $this
*/
public function setParseMode(?ParseMode $parse_mode): InputMediaVideo
{
$this->parse_mode = $parse_mode;
return $this;
}
/**
* Optional. List of special entities that appear in the caption, which can be specified instead of parse_mode
*
@ -83,6 +138,18 @@
return $this->caption_entities;
}
/**
* Sets the list of special entities that appear in the caption, which can be specified instead of parse_mode
*
* @param MessageEntity[]|null $caption_entities
* @return $this
*/
public function setCaptionEntities(?array $caption_entities): InputMediaVideo
{
$this->caption_entities = $caption_entities;
return $this;
}
/**
* Optional. Video width
*
@ -93,6 +160,18 @@
return $this->width;
}
/**
* Optional. Video width
*
* @param int|null $width
* @return $this
*/
public function setWidth(?int $width): InputMediaVideo
{
$this->width = $width;
return $this;
}
/**
* Optional. Video height
*
@ -103,6 +182,18 @@
return $this->height;
}
/**
* Optional. Video height
*
* @param int|null $height
* @return $this
*/
public function setHeight(?int $height): InputMediaVideo
{
$this->height = $height;
return $this;
}
/**
* Optional. Video duration in seconds
*
@ -113,6 +204,18 @@
return $this->duration;
}
/**
* Optional. Video duration in seconds
*
* @param int|null $duration
* @return $this
*/
public function setDuration(?int $duration): InputMediaVideo
{
$this->duration = $duration;
return $this;
}
/**
* Optional. Pass True if the uploaded video is suitable for streaming
*
@ -123,6 +226,18 @@
return $this->supports_streaming;
}
/**
* Optional. Pass True if the uploaded video is suitable for streaming
*
* @param bool $supports_streaming
* @return $this
*/
public function setSupportsStreaming(bool $supports_streaming): InputMediaVideo
{
$this->supports_streaming = $supports_streaming;
return $this;
}
/**
* Optional. Pass True if the video needs to be covered with a spoiler animation
*
@ -133,6 +248,18 @@
return $this->has_spoiler;
}
/**
* Optional. Pass True if the video needs to be covered with a spoiler animation
*
* @param bool $has_spoiler
* @return $this
*/
public function setHasSpoiler(bool $has_spoiler): InputMediaVideo
{
$this->has_spoiler = $has_spoiler;
return $this;
}
/**
* Returns an array representation of the object.
*
@ -140,28 +267,70 @@
*/
public function toArray(): array
{
return [
$array = [
'type' => $this->type->value,
'media' => $this->media,
'thumb' => $this->thumb,
'caption' => $this->caption,
'parse_mode' => $this->parse_mode->value,
'caption_entities' => array_map(fn(MessageEntity $item) => $item->toArray(), $this->caption_entities),
'width' => $this->width,
'height' => $this->height,
'duration' => $this->duration,
'supports_streaming' => $this->supports_streaming,
'has_spoiler' => $this->has_spoiler,
'media' => $this->media
];
if ($this->thumb !== null)
{
$array['thumb'] = $this->thumb;
}
if ($this->caption !== null)
{
$array['caption'] = $this->caption;
}
if ($this->parse_mode !== null)
{
$array['parse_mode'] = $this->parse_mode->value;
}
if ($this->caption_entities !== null)
{
$array['caption_entities'] = array_map(fn(MessageEntity $item) => $item->toArray(), $this->caption_entities);
}
if ($this->width !== null)
{
$array['width'] = $this->width;
}
if ($this->height !== null)
{
$array['height'] = $this->height;
}
if ($this->duration !== null)
{
$array['duration'] = $this->duration;
}
if ($this->supports_streaming)
{
$array['supports_streaming'] = $this->supports_streaming;
}
if ($this->has_spoiler)
{
$array['has_spoiler'] = $this->has_spoiler;
}
return $array;
}
/**
* @inheritDoc
*/
public static function fromArray(?array $data): InputMediaVideo
public static function fromArray(?array $data): ?InputMediaVideo
{
$object = new InputMediaVideo();
if($data === null)
{
return null;
}
$object = new InputMediaVideo();
$object->type = $data['type'] ?? null;
$object->media = $data['media'] ?? null;
$object->thumb = $data['thumb'] ?? null;