* Renamed namespace from \TgBotLib\Abstracts to \TgBotLib\Enums

* Updated class type to `final class` in `\TgBotLib\Enums > BotCommandScopeType`
 * Updated class type to `final class` in `\TgBotLib\Enums >  ChatActionType`
 * Updated class type to `final class` in `\TgBotLib\Enums > ChatMemberStatus`
 * Updated class type to `final class` in `\TgBotLib\Enums > ChatType`
 * Updated class type to `final class` in `\TgBotLib\Enums > EventType`
 * Updated class type to `final class` in `\TgBotLib\Enums > InlineQueryResultType`
 * Updated class type to `final class` in `\TgBotLib\Enums > InputMediaType`
 * Updated class type to `final class` in `\TgBotLib\Enums > InputButtonType`
 * Updated class type to `final class` in `\TgBotLib\Enums > MessageEntityType`
 * Updated class type to `final class` in `\TgBotLib\Enums > PassportElementType`
 * Updated class type to `final class` in `\TgBotLib\Enums > PollType`
 * Updated class type to `final class` in `\TgBotLib\Enums > StickerFormat`
 * Updated class type to `final class` in `\TgBotLib\Enums > StickerType`
 * Updated class type to `final class` in `\TgBotLib\Enums > ThumbnailMimeType`
 * Updated class type to `final class` in `\TgBotLib\Enums > UpdateEventType`
This commit is contained in:
Netkas 2023-08-09 15:32:45 -04:00
parent 176ea791bf
commit 5ec6f7271a
No known key found for this signature in database
GPG key ID: 5DAF58535614062B
56 changed files with 1279 additions and 332 deletions

View file

@ -4,7 +4,7 @@
namespace TgBotLib\Objects\Telegram\BotCommandScope;
use TgBotLib\Abstracts\BotCommandScopeType;
use TgBotLib\Enums\BotCommandScopeType;
use TgBotLib\Interfaces\ObjectTypeInterface;
use TgBotLib\Objects\Telegram\BotCommandScope;
@ -63,7 +63,7 @@
{
$object = new self();
$object->type = $data['type'] ?? BotCommandScopeType::AllChatAdministrators;
$object->type = $data['type'] ?? BotCommandScopeType::ALL_CHAT_ADMINISTRATORS;
$object->chat_id = $data['chat_id'] ?? null;
return $object;

View file

@ -4,7 +4,7 @@
namespace TgBotLib\Objects\Telegram\BotCommandScope;
use TgBotLib\Abstracts\BotCommandScopeType;
use TgBotLib\Enums\BotCommandScopeType;
use TgBotLib\Interfaces\ObjectTypeInterface;
use TgBotLib\Objects\Telegram\BotCommandScope;
@ -47,7 +47,7 @@
{
$object = new self();
$object->type = $data['type'] ?? BotCommandScopeType::AllGroupChats;
$object->type = $data['type'] ?? BotCommandScopeType::ALL_CHAT_GROUPS;
return $object;
}

View file

@ -4,7 +4,7 @@
namespace TgBotLib\Objects\Telegram\BotCommandScope;
use TgBotLib\Abstracts\BotCommandScopeType;
use TgBotLib\Enums\BotCommandScopeType;
use TgBotLib\Interfaces\ObjectTypeInterface;
use TgBotLib\Objects\Telegram\BotCommandScope;
@ -47,7 +47,7 @@
{
$object = new self();
$object->type = $data['type'] ?? BotCommandScopeType::AllPrivateChats;
$object->type = $data['type'] ?? BotCommandScopeType::ALL_PRIVATE_CHATS;
return $object;
}

View file

@ -4,7 +4,7 @@
namespace TgBotLib\Objects\Telegram\BotCommandScope;
use TgBotLib\Abstracts\BotCommandScopeType;
use TgBotLib\Enums\BotCommandScopeType;
use TgBotLib\Interfaces\ObjectTypeInterface;
use TgBotLib\Objects\Telegram\BotCommandScope;
@ -63,7 +63,7 @@
{
$object = new self();
$object->type = $data['type'] ?? BotCommandScopeType::Chat;
$object->type = $data['type'] ?? BotCommandScopeType::CHAT;
$object->chat_id = $data['chat_id'] ?? null;
return $object;

View file

@ -4,7 +4,7 @@
namespace TgBotLib\Objects\Telegram\BotCommandScope;
use TgBotLib\Abstracts\BotCommandScopeType;
use TgBotLib\Enums\BotCommandScopeType;
use TgBotLib\Interfaces\ObjectTypeInterface;
use TgBotLib\Objects\Telegram\BotCommandScope;
@ -47,7 +47,7 @@
{
$object = new self();
$object->type = $data['type'] ?? BotCommandScopeType::ChatAdministrators;
$object->type = $data['type'] ?? BotCommandScopeType::CHAT_ADMINISTRATORS;
return $object;
}

View file

@ -4,7 +4,7 @@
namespace TgBotLib\Objects\Telegram\BotCommandScope;
use TgBotLib\Abstracts\BotCommandScopeType;
use TgBotLib\Enums\BotCommandScopeType;
use TgBotLib\Interfaces\ObjectTypeInterface;
use TgBotLib\Objects\Telegram\BotCommandScope;
@ -79,7 +79,7 @@
{
$object = new self();
$object->type = $data['type'] ?? BotCommandScopeType::ChatMember;
$object->type = $data['type'] ?? BotCommandScopeType::CHAT_MEMBER;
$object->chat_id = $data['chat_id'] ?? null;
$object->user_id = $data['user_id'] ?? null;

View file

@ -4,7 +4,7 @@
namespace TgBotLib\Objects\Telegram\BotCommandScope;
use TgBotLib\Abstracts\BotCommandScopeType;
use TgBotLib\Enums\BotCommandScopeType;
use TgBotLib\Interfaces\ObjectTypeInterface;
use TgBotLib\Objects\Telegram\BotCommandScope;
@ -47,7 +47,7 @@
{
$object = new self();
$object->type = $data['type'] ?? BotCommandScopeType::Default;
$object->type = $data['type'] ?? BotCommandScopeType::DEFAULT;
return $object;
}

View file

@ -4,7 +4,7 @@
namespace TgBotLib\Objects\Telegram;
use TgBotLib\Abstracts\ChatType;
use TgBotLib\Enums\ChatType;
use TgBotLib\Interfaces\ObjectTypeInterface;
class Chat implements ObjectTypeInterface

View file

@ -4,7 +4,7 @@
namespace TgBotLib\Objects\Telegram\ChatMember;
use TgBotLib\Abstracts\ChatMemberStatus;
use TgBotLib\Enums\ChatMemberStatus;
use TgBotLib\Interfaces\ObjectTypeInterface;
use TgBotLib\Objects\Telegram\ChatMember;
use TgBotLib\Objects\Telegram\User;
@ -292,7 +292,7 @@
{
$object = new self();
$object->status = $data['status'] ?? ChatMemberStatus::Administrator;
$object->status = $data['status'] ?? ChatMemberStatus::ADMINISTRATOR;
$object->user = isset($data['user']) ? User::fromArray($data['user']) : null;
$object->can_be_edited = $data['can_be_edited'] ?? false;
$object->is_anonymous = $data['is_anonymous'] ?? false;

View file

@ -4,7 +4,7 @@
namespace TgBotLib\Objects\Telegram\ChatMember;
use TgBotLib\Abstracts\ChatMemberStatus;
use TgBotLib\Enums\ChatMemberStatus;
use TgBotLib\Interfaces\ObjectTypeInterface;
use TgBotLib\Objects\Telegram\ChatMember;
use TgBotLib\Objects\Telegram\User;
@ -80,7 +80,7 @@
{
$object = new self();
$object->status = $data['status'] ?? ChatMemberStatus::Kicked;
$object->status = $data['status'] ?? ChatMemberStatus::KICKED;
$object->user = isset($data['user']) ? User::fromArray($data['user']) : null;
$object->until_date = $data['until_date'] ?? null;

View file

@ -4,7 +4,7 @@
namespace TgBotLib\Objects\Telegram\ChatMember;
use TgBotLib\Abstracts\ChatMemberStatus;
use TgBotLib\Enums\ChatMemberStatus;
use TgBotLib\Interfaces\ObjectTypeInterface;
use TgBotLib\Objects\Telegram\ChatMember;
use TgBotLib\Objects\Telegram\User;
@ -64,7 +64,7 @@
{
$object = new self();
$object->status = $data['status'] ?? ChatMemberStatus::Left;
$object->status = $data['status'] ?? ChatMemberStatus::LEFT;
$object->user = isset($data['user']) ? User::fromArray($data['user']) : null;
return $object;

View file

@ -4,7 +4,7 @@
namespace TgBotLib\Objects\Telegram\ChatMember;
use TgBotLib\Abstracts\ChatMemberStatus;
use TgBotLib\Enums\ChatMemberStatus;
use TgBotLib\Interfaces\ObjectTypeInterface;
use TgBotLib\Objects\Telegram\ChatMember;
use TgBotLib\Objects\Telegram\User;
@ -64,7 +64,7 @@
{
$object = new self();
$object->status = $data['status'] ?? ChatMemberStatus::Member;
$object->status = $data['status'] ?? ChatMemberStatus::MEMBER;
$object->user = isset($data['user']) ? User::fromArray($data['user']) : null;
return $object;

View file

@ -4,7 +4,7 @@
namespace TgBotLib\Objects\Telegram\ChatMember;
use TgBotLib\Abstracts\ChatMemberStatus;
use TgBotLib\Enums\ChatMemberStatus;
use TgBotLib\Interfaces\ObjectTypeInterface;
use TgBotLib\Objects\Telegram\ChatMember;
use TgBotLib\Objects\Telegram\User;
@ -96,7 +96,7 @@
{
$object = new ChatMemberOwner();
$object->status = $data['status'] ?? ChatMemberStatus::Creator;
$object->status = $data['status'] ?? ChatMemberStatus::CREATOR;
$object->user = isset($data['user']) ? User::fromArray($data['user']) : null;
$object->is_anonymous = $data['is_anonymous'] ?? false;
$object->custom_title = $data['custom_title'] ?? null;

View file

@ -4,7 +4,7 @@
namespace TgBotLib\Objects\Telegram\ChatMember;
use TgBotLib\Abstracts\ChatMemberStatus;
use TgBotLib\Enums\ChatMemberStatus;
use TgBotLib\Interfaces\ObjectTypeInterface;
use TgBotLib\Objects\Telegram\ChatMember;
use TgBotLib\Objects\Telegram\User;
@ -321,7 +321,7 @@
{
$object = new static();
$object->status = $data['status'] ?? ChatMemberStatus::Restricted;
$object->status = $data['status'] ?? ChatMemberStatus::RESTRICTED;
$object->user = isset($data['user']) ? User::fromArray($data['user']) : null;
$object->is_member = $data['is_member'] ?? false;
$object->can_send_messages = $data['can_send_messages'] ?? false;

View file

@ -3,7 +3,7 @@
namespace TgBotLib\Objects\Telegram;
use InvalidArgumentException;
use TgBotLib\Abstracts\InlineQueryResultType;
use TgBotLib\Enums\InlineQueryResultType;
use TgBotLib\Exceptions\NotImplementedException;
use TgBotLib\Interfaces\ObjectTypeInterface;
use TgBotLib\Objects\Telegram\InlineQueryResult\InlineQueryResultArticle;
@ -49,32 +49,32 @@
switch(strtolower($data['type']))
{
case InlineQueryResultType::Article:
case InlineQueryResultType::ARTICLE:
return InlineQueryResultArticle::fromArray($data);
case InlineQueryResultType::Photo:
case InlineQueryResultType::PHOTO:
return InlineQueryResultPhoto::fromArray($data);
case InlineQueryResultType::Gif:
case InlineQueryResultType::GIF:
return InlineQueryResultGif::fromArray($data);
case InlineQueryResultType::Mpeg4Gif:
case InlineQueryResultType::MPEG_4_GIF:
return InlineQueryResultMpeg4Gif::fromArray($data);
case InlineQueryResultType::Video:
case InlineQueryResultType::VIDEO:
return InlineQueryResultVideo::fromArray($data);
case InlineQueryResultType::Audio:
case InlineQueryResultType::AUDIO:
return InlineQueryResultAudio::fromArray($data);
case InlineQueryResultType::Voice:
case InlineQueryResultType::VOICE:
return InlineQueryResultVoice::fromArray($data);
case InlineQueryResultType::Document:
case InlineQueryResultType::DOCUMENT:
return InlineQueryResultDocument::fromArray($data);
case InlineQueryResultType::Location:
case InlineQueryResultType::LOCATION:
return InlineQueryResultLocation::fromArray($data);
case InlineQueryResultType::Venue:
case InlineQueryResultType::VENUE:
return InlineQueryResultVenue::fromArray($data);
case InlineQueryResultType::Contact:
case InlineQueryResultType::CONTACT:
return InlineQueryResultContact::fromArray($data);
case InlineQueryResultType::Game:
case InlineQueryResultType::GAME:
return InlineQueryResultGame::fromArray($data);
default:
throw new InvalidArgumentException(sprintf('The type of the InlineQueryResult is invalid, got "%s", expected one of "%s"', $data['type'], implode('", "', InlineQueryResultType::All)));
throw new InvalidArgumentException(sprintf('The type of the InlineQueryResult is invalid, got "%s", expected one of "%s"', $data['type'], implode('", "', InlineQueryResultType::ALL)));
}
}
}

View file

@ -1,9 +1,12 @@
<?php
/** @noinspection PhpUnused */
/** @noinspection PhpMissingFieldTypeInspection */
namespace TgBotLib\Objects\Telegram\InlineQueryResult;
use InvalidArgumentException;
use TgBotLib\Classes\Validate;
use TgBotLib\Interfaces\ObjectTypeInterface;
use TgBotLib\Objects\Telegram\InlineKeyboardMarkup;
use TgBotLib\Objects\Telegram\InputMessageContent;
@ -97,6 +100,22 @@
return $this->id;
}
/**
* Sets the value of the 'id' field.
* Unique identifier for this result, 1-64 Bytes
*
* @param string $id
* @return $this
*/
public function setId(string $id): InlineQueryResultArticle
{
if(!Validate::length($id, 1, 64))
throw new InvalidArgumentException('id should be between 1-64 characters');
$this->id = $id;
return $this;
}
/**
* Title of the result
*
@ -107,6 +126,19 @@
return $this->title;
}
/**
* Sets the value of the 'title' field.
* Title of the result
*
* @param string $title
* @return $this
*/
public function setTitle(string $title): InlineQueryResultArticle
{
$this->title = $title;
return $this;
}
/**
* Content of the message to be sent
*
@ -117,6 +149,19 @@
return $this->input_message_content;
}
/**
* Sets the value of the 'input_message_content' field.
* Content of the message to be sent
*
* @param InputContactMessageContent|InputLocationMessageContent|InputTextMessageContent|InputVenueMessageContent|null $input_message_content
* @return $this
*/
public function setInputMessageContent(InputVenueMessageContent|InputTextMessageContent|InputContactMessageContent|InputLocationMessageContent|null $input_message_content): InlineQueryResultArticle
{
$this->input_message_content = $input_message_content;
return $this;
}
/**
* Optional. Inline keyboard attached to the message
*
@ -127,6 +172,19 @@
return $this->reply_markup;
}
/**
* Sets the value of the 'reply_markup' field.
* Optional. Inline keyboard attached to the message
*
* @param InlineKeyboardMarkup|null $reply_markup
* @return $this
*/
public function setReplyMarkup(?InlineKeyboardMarkup $reply_markup): InlineQueryResultArticle
{
$this->reply_markup = $reply_markup;
return $this;
}
/**
* Optional. URL of the result
*
@ -137,6 +195,22 @@
return $this->url;
}
/**
* Sets the value of the 'url' field.
* Optional. URL of the result
*
* @param string|null $url
* @return $this
*/
public function setUrl(?string $url): InlineQueryResultArticle
{
if(!Validate::url($url))
throw new InvalidArgumentException(sprintf('url is not a valid url: %s', $url));
$this->url = $url;
return $this;
}
/**
* Optional. Pass True if you don't want the URL to be shown in the message
*
@ -147,6 +221,19 @@
return $this->hide_url;
}
/**
* Sets the value of the 'hide_url' field.
* Optional. Pass True if you don't want the URL to be shown in the message
*
* @param bool $hide_url
* @return $this
*/
public function setHideUrl(bool $hide_url): InlineQueryResultArticle
{
$this->hide_url = $hide_url;
return $this;
}
/**
* Optional. Short description of the result
*
@ -157,6 +244,19 @@
return $this->description;
}
/**
* Sets the value of the 'description' field.
* Optional. Short description of the result
*
* @param string|null $description
* @return $this
*/
public function setDescription(?string $description): InlineQueryResultArticle
{
$this->description = $description;
return $this;
}
/**
* Optional. Url of the thumbnail for the result
*
@ -167,6 +267,22 @@
return $this->thumbnail_url;
}
/**
* Sets the value of the 'thumbnail_url' field.
* Optional. Url of the thumbnail for the result
*
* @param string|null $thumbnail_url
* @return $this
*/
public function setThumbnailUrl(?string $thumbnail_url): InlineQueryResultArticle
{
if(!Validate::url($thumbnail_url))
throw new InvalidArgumentException(sprintf('thumbnail_url is not a valid url: %s', $thumbnail_url));
$this->thumbnail_url = $thumbnail_url;
return $this;
}
/**
* Optional. Thumbnail width
*
@ -177,6 +293,19 @@
return $this->thumbnail_width;
}
/**
* Sets the value of the 'thumbnail_width' field.
* Optional. Thumbnail width
*
* @param int|null $thumbnail_width
* @return $this
*/
public function setThumbnailWidth(?int $thumbnail_width): InlineQueryResultArticle
{
$this->thumbnail_width = $thumbnail_width;
return $this;
}
/**
* Optional. Thumbnail height
*
@ -187,6 +316,19 @@
return $this->thumbnail_height;
}
/**
* Sets the value of the 'thumbnail_height' field.
* Optional. Thumbnail height
*
* @param int|null $thumbnail_height
* @return $this
*/
public function setThumbnailHeight(?int $thumbnail_height): InlineQueryResultArticle
{
$this->thumbnail_height = $thumbnail_height;
return $this;
}
/**
* Returns an array representation of the object
*

View file

@ -1,9 +1,12 @@
<?php
/** @noinspection PhpUnused */
/** @noinspection PhpMissingFieldTypeInspection */
namespace TgBotLib\Objects\Telegram\InlineQueryResult;
use InvalidArgumentException;
use TgBotLib\Classes\Validate;
use TgBotLib\Interfaces\ObjectTypeInterface;
use TgBotLib\Objects\Telegram\InlineKeyboardMarkup;
use TgBotLib\Objects\Telegram\InputMessageContent\InputContactMessageContent;
@ -98,6 +101,24 @@
return $this->id;
}
/**
* Sets the value of 'id' property
* Unique identifier for this result, 1-64 bytes
*
* @param string $id
* @return $this
*/
public function setId(string $id): InlineQueryResultAudio
{
if(!Validate::length($id, 1, 64))
{
throw new InvalidArgumentException(sprintf('id must be between 1 and 64 characters long, got %s characters', $id));
}
$this->id = $id;
return $this;
}
/**
* A valid URL for the audio file
*
@ -108,6 +129,22 @@
return $this->audio_url;
}
/**
* Sets the value of 'audio_url' property
* A valid URL for the audio file
*
* @param string $audio_url
* @return $this
*/
public function setAudioUrl(string $audio_url): InlineQueryResultAudio
{
if(!Validate::url($audio_url))
throw new InvalidArgumentException(sprintf('audio_url is not a valid URL: %s', $audio_url));
$this->audio_url = $audio_url;
return $this;
}
/**
* Title
*
@ -118,6 +155,19 @@
return $this->title;
}
/**
* Sets the value of 'title' property
* Title
*
* @param string $title
* @return $this
*/
public function setTitle(string $title): InlineQueryResultAudio
{
$this->title = $title;
return $this;
}
/**
* Optional. Caption, 0-1024 characters after entities parsing
*
@ -128,6 +178,28 @@
return $this->caption;
}
/**
* Sets the value of 'caption' property
* Optional. Caption, 0-1024 characters after entities parsing
*
* @param string|null $caption
* @return $this
*/
public function setCaption(?string $caption): InlineQueryResultAudio
{
if($caption == null)
{
$this->caption = null;
return $this;
}
if(!Validate::length($caption, 0, 1024))
throw new InvalidArgumentException(sprintf('caption must be between 0 and 1024 characters long, got %s characters', $caption));
$this->caption = $caption;
return $this;
}
/**
* Optional. Mode for parsing entities in the audio caption. See formatting options for more details.
*
@ -138,6 +210,28 @@
return $this->parse_mode;
}
/**
* Sets the value of 'parse_mode' property
* Optional. Mode for parsing entities in the audio caption. See formatting options for more details.
*
* @param string|null $parse_mode
* @return $this
*/
public function setParseMode(?string $parse_mode): InlineQueryResultAudio
{
if($parse_mode == null)
{
$this->parse_mode = null;
return $this;
}
if(!in_array(strtolower($parse_mode), ['markdown', 'html']))
throw new InvalidArgumentException(sprintf('parse_mode must be one of Markdown, HTML, got %s', $parse_mode));
$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
*
@ -148,6 +242,34 @@
return $this->caption_entities;
}
/**
* Sets the value of 'caption_entities' property
* Optional. 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): InlineQueryResultAudio
{
if($caption_entities == null)
{
$this->caption_entities = null;
return $this;
}
$this->caption_entities = [];
foreach($caption_entities as $entity)
{
if(!$entity instanceof MessageEntity)
throw new InvalidArgumentException(sprintf('caption_entities must be array of MessageEntity, got %s', gettype($entity)));
$this->caption_entities[] = $entity;
}
return $this;
}
/**
* Optional. Performer
*
@ -158,6 +280,25 @@
return $this->performer;
}
/**
* Sets the value of 'performer' property
* Optional. Performer
*
* @param string|null $performer
* @return $this
*/
public function setPerformer(?string $performer): InlineQueryResultAudio
{
if($performer == null)
{
$this->performer = null;
return $this;
}
$this->performer = $performer;
return $this;
}
/**
* Optional. Audio duration in seconds
*
@ -168,6 +309,25 @@
return $this->audio_duration;
}
/**
* Sets the value of 'audio_duration' property
* Optional. Audio duration in seconds
*
* @param int|null $audio_duration
* @return $this
*/
public function setAudioDuration(?int $audio_duration): InlineQueryResultAudio
{
if($audio_duration == null)
{
$this->audio_duration = null;
return $this;
}
$this->audio_duration = $audio_duration;
return $this;
}
/**
* Optional. Inline keyboard attached to the message
*
@ -178,6 +338,19 @@
return $this->reply_markup;
}
/**
* Sets the value of 'reply_markup' property
* Optional. Inline keyboard attached to the message
*
* @param InlineKeyboardMarkup|null $reply_markup
* @return $this
*/
public function setReplyMarkup(?InlineKeyboardMarkup $reply_markup): InlineQueryResultAudio
{
$this->reply_markup = $reply_markup;
return $this;
}
/**
* Optional. Content of the message to be sent instead of the audio
*
@ -188,6 +361,19 @@
return $this->input_message_content;
}
/**
* Sets the value of 'input_message_content' property
* Optional. Content of the message to be sent instead of the audio
*
* @param InputContactMessageContent|InputInvoiceMessageContent|InputLocationMessageContent|InputTextMessageContent|InputVenueMessageContent|null $input_message_content
* @return $this
*/
public function setInputMessageContent(InputVenueMessageContent|InputTextMessageContent|InputContactMessageContent|InputLocationMessageContent|InputInvoiceMessageContent|null $input_message_content): InlineQueryResultAudio
{
$this->input_message_content = $input_message_content;
return $this;
}
/**
* Returns an array representation of the object
*

View file

@ -1,9 +1,12 @@
<?php
/** @noinspection PhpUnused */
/** @noinspection PhpMissingFieldTypeInspection */
namespace TgBotLib\Objects\Telegram\InlineQueryResult;
use InvalidArgumentException;
use TgBotLib\Classes\Validate;
use TgBotLib\Interfaces\ObjectTypeInterface;
use TgBotLib\Objects\Telegram\InlineKeyboardMarkup;
use TgBotLib\Objects\Telegram\InputMessageContent;
@ -98,6 +101,22 @@
return $this->id;
}
/**
* Sets the value of 'id' property
* Unique identifier for this result, 1-64 Bytes
*
* @param string $id
* @return $this
*/
public function setId(string $id): self
{
if(!Validate::length($id, 1, 64))
throw new InvalidArgumentException('id should be between 1-64 characters');
$this->id = $id;
return $this;
}
/**
* Contact's phone number
*
@ -108,6 +127,19 @@
return $this->phone_number;
}
/**
* Sets the value of 'phone_number' property
* Contact's phone number
*
* @param string $phone_number
* @return $this
*/
public function setPhoneNumber(string $phone_number): self
{
$this->phone_number = $phone_number;
return $this;
}
/**
* Contact's first name
*
@ -118,6 +150,19 @@
return $this->first_name;
}
/**
* Sets the value of 'first_name' property
* Contact's first name
*
* @param string $first_name
* @return $this
*/
public function setFirstName(string $first_name): self
{
$this->first_name = $first_name;
return $this;
}
/**
* Optional. Contact's last name
*
@ -128,6 +173,19 @@
return $this->last_name;
}
/**
* Sets the value of 'last_name' property
* Optional. Contact's last name
*
* @param string|null $last_name
* @return $this
*/
public function setLastName(?string $last_name): self
{
$this->last_name = $last_name;
return $this;
}
/**
* Optional. Additional data about the contact in the form of a vCard, 0-2048 bytes
*
@ -138,6 +196,22 @@
return $this->vcard;
}
/**
* Sets the value of 'vcard' property
* Optional. Additional data about the contact in the form of a vCard, 0-2048 bytes
*
* @param string|null $vcard
* @return $this
*/
public function setVcard(?string $vcard): self
{
if(!Validate::length($vcard, 0, 2048))
throw new InvalidArgumentException('vcard should be between 0-2048 characters');
$this->vcard = $vcard;
return $this;
}
/**
* Optional. Inline keyboard attached to the message
*
@ -148,6 +222,19 @@
return $this->reply_markup;
}
/**
* Sets the value of 'reply_markup' property
* Optional. Inline keyboard attached to the message
*
* @param InlineKeyboardMarkup|null $reply_markup
* @return $this
*/
public function setReplyMarkup(?InlineKeyboardMarkup $reply_markup): self
{
$this->reply_markup = $reply_markup;
return $this;
}
/**
* Optional. Content of the message to be sent instead of the contact
*
@ -158,6 +245,19 @@
return $this->input_message_content;
}
/**
* Sets the value of 'input_message_content' property
* Optional. Content of the message to be sent instead of the contact
*
* @param InputContactMessageContent|InputInvoiceMessageContent|InputLocationMessageContent|InputTextMessageContent|InputVenueMessageContent|null $input_message_content
* @return $this
*/
public function setInputMessageContent(InputVenueMessageContent|InputTextMessageContent|InputContactMessageContent|InputLocationMessageContent|InputInvoiceMessageContent|null $input_message_content): self
{
$this->input_message_content = $input_message_content;
return $this;
}
/**
* Optional. Url of the thumbnail for the result
*
@ -168,6 +268,19 @@
return $this->thumbnail_url;
}
/**
* Sets the value of 'thumbnail_url' property
* Optional. Url of the thumbnail for the result
*
* @param string|null $thumbnail_url
* @return $this
*/
public function setThumbnailUrl(?string $thumbnail_url): self
{
$this->thumbnail_url = $thumbnail_url;
return $this;
}
/**
* Optional. Thumbnail width
*
@ -178,6 +291,19 @@
return $this->thumbnail_width;
}
/**
* Sets the value of 'thumbnail_width' property
* Optional. Thumbnail width
*
* @param int|null $thumbnail_width
* @return $this
*/
public function setThumbnailWidth(?int $thumbnail_width): self
{
$this->thumbnail_width = $thumbnail_width;
return $this;
}
/**
* Optional. Thumbnail height
*
@ -188,6 +314,19 @@
return $this->thumbnail_height;
}
/**
* Sets the value of 'thumbnail_height' property
* Optional. Thumbnail height
*
* @param int|null $thumbnail_height
* @return $this
*/
public function setThumbnailHeight(?int $thumbnail_height): self
{
$this->thumbnail_height = $thumbnail_height;
return $this;
}
/**
* Returns an array representation of the object
*

View file

@ -1,9 +1,12 @@
<?php
/** @noinspection PhpUnused */
/** @noinspection PhpMissingFieldTypeInspection */
namespace TgBotLib\Objects\Telegram\InlineQueryResult;
use InvalidArgumentException;
use TgBotLib\Classes\Validate;
use TgBotLib\Interfaces\ObjectTypeInterface;
use TgBotLib\Objects\Telegram\InlineKeyboardMarkup;
use TgBotLib\Objects\Telegram\InputMessageContent\InputContactMessageContent;
@ -123,6 +126,19 @@
return $this->title;
}
/**
* Sets the value of the 'title' field.
* Title for the result
*
* @param string $title
* @return $this
*/
public function setTitle(string $title): InlineQueryResultDocument
{
$this->title = $title;
return $this;
}
/**
* Optional. Caption of the document to be sent, 0-1024 characters after entities parsing
*
@ -133,6 +149,30 @@
return $this->caption;
}
/**
* Sets the value of the 'caption' field.
* Optional. Caption of the document to be sent, 0-1024 characters after entities parsing
*
* @param string|null $caption
* @return $this
*/
public function setCaption(?string $caption): InlineQueryResultDocument
{
if($caption == null)
{
$this->caption = null;
return $this;
}
if(!Validate::length($caption, 0, 1024))
{
throw new InvalidArgumentException("Caption must be between 0 and 1024 characters");
}
$this->caption = $caption;
return $this;
}
/**
* Optional. Mode for parsing entities in the document caption. See formatting options for more details.
*
@ -143,6 +183,30 @@
return $this->parse_mode;
}
/**
* Sets the value of the 'parse_mode' field.
* Optional. Mode for parsing entities in the document caption. See formatting options for more details.
*
* @param string|null $parse_mode
* @return $this
*/
public function setParseMode(?string $parse_mode): InlineQueryResultDocument
{
if($parse_mode == null)
{
$this->parse_mode = null;
return $this;
}
if(!in_array(strtolower($parse_mode), ['markdown', 'html']))
{
throw new InvalidArgumentException("Parse mode must be either Markdown or HTML");
}
$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
*
@ -153,6 +217,33 @@
return $this->caption_entities;
}
/**
* Sets the value of the 'caption_entities' field.
* Optional. 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): InlineQueryResultDocument
{
if($caption_entities == null)
{
$this->caption_entities = null;
return $this;
}
foreach($caption_entities as $entity)
{
if(!($entity instanceof MessageEntity))
{
throw new InvalidArgumentException("Caption entities must be an array of MessageEntity");
}
}
$this->caption_entities = $caption_entities;
return $this;
}
/**
* A valid URL for the file
*
@ -163,6 +254,24 @@
return $this->document_url;
}
/**
* Sets the value of the 'document_url' field.
* A valid URL for the file
*
* @param string $document_url
* @return $this
*/
public function setDocumentUrl(string $document_url): InlineQueryResultDocument
{
if(!Validate::url($document_url))
{
throw new InvalidArgumentException("Document URL must be a valid URL");
}
$this->document_url = $document_url;
return $this;
}
/**
* MIME type of the content of the file, either “application/pdf” or “application/zip”
*
@ -173,6 +282,19 @@
return $this->mime_type;
}
/**
* Sets the value of the 'mime_type' field.
* MIME type of the content of the file, either “application/pdf” or “application/zip”
*
* @param string $mime_type
* @return $this
*/
public function setMimeType(string $mime_type): InlineQueryResultDocument
{
$this->mime_type = $mime_type;
return $this;
}
/**
* Optional. Short description of the result
*
@ -183,6 +305,19 @@
return $this->description;
}
/**
* Sets the value of the 'description' field.
* Optional. Short description of the result
*
* @param string|null $description
* @return $this
*/
public function setDescription(?string $description): InlineQueryResultDocument
{
$this->description = $description;
return $this;
}
/**
* Optional. Inline keyboard attached to the message
*
@ -193,6 +328,19 @@
return $this->reply_markup;
}
/**
* Sets the value of the 'reply_markup' field.
* Optional. Inline keyboard attached to the message
*
* @param InlineKeyboardMarkup|null $reply_markup
* @return $this
*/
public function setReplyMarkup(?InlineKeyboardMarkup $reply_markup): InlineQueryResultDocument
{
$this->reply_markup = $reply_markup;
return $this;
}
/**
* Optional. Content of the message to be sent instead of the file
*
@ -203,6 +351,19 @@
return $this->input_message_content;
}
/**
* Sets the value of the 'input_message_content' field.
* Optional. Content of the message to be sent instead of the file
*
* @param InputContactMessageContent|InputInvoiceMessageContent|InputLocationMessageContent|InputTextMessageContent|InputVenueMessageContent|null $input_message_content
* @return $this
*/
public function setInputMessageContent(InputVenueMessageContent|InputTextMessageContent|InputContactMessageContent|InputLocationMessageContent|InputInvoiceMessageContent|null $input_message_content): InlineQueryResultDocument
{
$this->input_message_content = $input_message_content;
return $this;
}
/**
* Optional. URL of the thumbnail (JPEG only) for the file
*
@ -213,6 +374,24 @@
return $this->thumbnail_url;
}
/**
* Sets the value of the 'thumbnail_url' field.
* Optional. URL of the thumbnail (JPEG only) for the file
*
* @param string|null $thumbnail_url
* @return $this
*/
public function setThumbnailUrl(?string $thumbnail_url): InlineQueryResultDocument
{
if($thumbnail_url != null && !Validate::url($thumbnail_url))
{
throw new InvalidArgumentException("Thumbnail URL must be a valid URL");
}
$this->thumbnail_url = $thumbnail_url;
return $this;
}
/**
* Optional. Thumbnail width
*
@ -223,6 +402,19 @@
return $this->thumbnail_width;
}
/**
* Sets the value of the 'thumbnail_width' field.
* Optional. Thumbnail width
*
* @param int|null $thumbnail_width
* @return $this
*/
public function setThumbnailWidth(?int $thumbnail_width): InlineQueryResultDocument
{
$this->thumbnail_width = $thumbnail_width;
return $this;
}
/**
* Optional. Thumbnail height
*
@ -233,6 +425,19 @@
return $this->thumbnail_height;
}
/**
* Sets the value of the 'thumbnail_height' field.
* Optional. Thumbnail height
*
* @param int|null $thumbnail_height
* @return $this
*/
public function setThumbnailHeight(?int $thumbnail_height): InlineQueryResultDocument
{
$this->thumbnail_height = $thumbnail_height;
return $this;
}
/**
* Returns an array representation of the object
*

View file

@ -1,5 +1,6 @@
<?php
/** @noinspection PhpUnused */
/** @noinspection PhpMissingFieldTypeInspection */
namespace TgBotLib\Objects\Telegram\InlineQueryResult;
@ -49,6 +50,19 @@
return $this->id;
}
/**
* Sets the value of the 'id' field
* Unique identifier for this result, 1-64 bytes
*
* @param string $id
* @return InlineQueryResultGame
*/
public function setId(string $id): InlineQueryResultGame
{
$this->id = $id;
return $this;
}
/**
* Short name of the game
*
@ -59,6 +73,19 @@
return $this->game_short_name;
}
/**
* Sets the value of the 'game_short_name' field
* Short name of the game
*
* @param string $game_short_name
* @return InlineQueryResultGame
*/
public function setGameShortName(string $game_short_name): InlineQueryResultGame
{
$this->game_short_name = $game_short_name;
return $this;
}
/**
* Optional. Inline keyboard attached to the message
*
@ -69,6 +96,18 @@
return $this->reply_markup;
}
/**
* Optional. Inline keyboard attached to the message
*
* @param InlineKeyboardMarkup|null $reply_markup
* @return InlineQueryResultGame
*/
public function setReplyMarkup(?InlineKeyboardMarkup $reply_markup): InlineQueryResultGame
{
$this->reply_markup = $reply_markup;
return $this;
}
/**
* Returns an array representation of the object
*

View file

@ -5,7 +5,9 @@
namespace TgBotLib\Objects\Telegram\InlineQueryResult;
use TgBotLib\Abstracts\ThumbnailMimeType;
use InvalidArgumentException;
use TgBotLib\Enums\ThumbnailMimeType;
use TgBotLib\Classes\Validate;
use TgBotLib\Interfaces\ObjectTypeInterface;
use TgBotLib\Objects\Telegram\InlineKeyboardMarkup;
use TgBotLib\Objects\Telegram\InputMessageContent\InputContactMessageContent;
@ -116,6 +118,24 @@
return $this->id;
}
/**
* Sets the value of the 'id' field.
* Unique identifier for this result, 1-64 bytes
*
* @param string $id
* @return $this
*/
public function setId(string $id): InlineQueryResultGif
{
if(!Validate::length($id, 1, 64))
{
throw new InvalidArgumentException();
}
$this->id = $id;
return $this;
}
/**
* A valid URL for the GIF file. File size must not exceed 1MB
*
@ -126,6 +146,24 @@
return $this->gif_url;
}
/**
* Sets the value of the 'gif_url' field.
* A valid URL for the GIF file. File size must not exceed 1MB
*
* @param string $gif_url
* @return $this
*/
public function setGifUrl(string $gif_url): InlineQueryResultGif
{
if(!Validate::url($gif_url))
{
throw new InvalidArgumentException(sprintf('"%s" is not a valid url', $gif_url));
}
$this->gif_url = $gif_url;
return $this;
}
/**
* Optional. Width of the GIF
*
@ -136,6 +174,19 @@
return $this->gif_width;
}
/**
* Sets the value of the 'gif_width' field.
* Optional. Width of the GIF
*
* @param int $gif_width
* @return $this
*/
public function setGifWidth(int $gif_width): InlineQueryResultGif
{
$this->gif_width = $gif_width;
return $this;
}
/**
* Optional. Height of the GIF
*
@ -146,6 +197,25 @@
return $this->gif_height;
}
/**
* Sets the value of the 'gif_height' field.
* Optional. Height of the GIF
*
* @param int|null $gif_height
* @return $this
*/
public function setGifHeight(?int $gif_height): InlineQueryResultGif
{
if(is_null($gif_height))
{
$this->gif_height = null;
return $this;
}
$this->gif_height = $gif_height;
return $this;
}
/**
* Optional. Duration of the GIF in seconds
*
@ -156,6 +226,25 @@
return $this->gif_duration;
}
/**
* Sets the value of the 'gif_duration' field.
* Optional. Duration of the GIF in seconds
*
* @param int|null $gif_duration
* @return $this
*/
public function setGifDuration(?int $gif_duration): InlineQueryResultGif
{
if(is_null($gif_duration))
{
$this->gif_duration = null;
return $this;
}
$this->gif_duration = $gif_duration;
return $this;
}
/**
* URL of the static (JPEG or GIF) or animated (MPEG4) thumbnail for the result
*
@ -166,6 +255,24 @@
return $this->thumbnail_url;
}
/**
* Sets the value of the 'thumbnail_url' field.
* URL of the static (JPEG or GIF) or animated (MPEG4) thumbnail for the result
*
* @param string $thumbnail_url
* @return $this
*/
public function setThumbnailUrl(string $thumbnail_url): InlineQueryResultGif
{
if(!Validate::url($thumbnail_url))
{
throw new InvalidArgumentException(sprintf('"%s" is not a valid url', $thumbnail_url));
}
$this->thumbnail_url = $thumbnail_url;
return $this;
}
/**
* Optional. MIME type of the thumbnail, must be one of “image/jpeg”, “image/gif”, or “video/mp4”. Defaults to “image/jpeg”
*
@ -176,6 +283,25 @@
return $this->thumbnail_mime_type;
}
/**
* Sets the value of the 'thumbnail_mime_type' field.
* Optional. MIME type of the thumbnail, must be one of “image/jpeg”, “image/gif”, or “video/mp4”. Defaults to “image/jpeg”
*
* @param string|null $thumbnail_mime_type
* @return $this
*/
public function setThumbnailMimeType(?string $thumbnail_mime_type): InlineQueryResultGif
{
if(is_null($thumbnail_mime_type))
{
$this->thumbnail_mime_type = null;
return $this;
}
$this->thumbnail_mime_type = $thumbnail_mime_type;
return $this;
}
/**
* Optional. Title for the result
*
@ -186,6 +312,19 @@
return $this->title;
}
/**
* Sets the value of the 'title' field.
* Optional. Title for the result
*
* @param string|null $title
* @return $this
*/
public function setTitle(?string $title): InlineQueryResultGif
{
$this->title = $title;
return $this;
}
/**
* Optional. Caption of the GIF file to be sent, 0-1024 characters after entities parsing
*
@ -196,6 +335,19 @@
return $this->caption;
}
/**
* Sets the value of the 'caption' field.
* Optional. Caption of the GIF file to be sent, 0-1024 characters after entities parsing
*
* @param string|null $caption
* @return $this
*/
public function setCaption(?string $caption): InlineQueryResultGif
{
$this->caption = $caption;
return $this;
}
/**
* Optional. Mode for parsing entities in the caption. See formatting options for more details.
*
@ -206,6 +358,19 @@
return $this->parse_mode;
}
/**
* Sets the value of the 'parse_mode' field.
* Optional. Mode for parsing entities in the caption. See formatting options for more details.
*
* @param string|null $parse_mode
* @return $this
*/
public function setParseMode(?string $parse_mode): InlineQueryResultGif
{
$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
*
@ -216,6 +381,34 @@
return $this->caption_entities;
}
/**
* Sets the value of the 'caption_entities' field.
* Optional. 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): InlineQueryResultGif
{
if($caption_entities == null)
{
$this->caption_entities = null;
return $this;
}
$this->caption_entities = [];
foreach($caption_entities as $entity)
{
if(!$entity instanceof MessageEntity)
throw new InvalidArgumentException(sprintf('caption_entities must be array of MessageEntity, got %s', gettype($entity)));
$this->caption_entities[] = $entity;
}
return $this;
}
/**
* Optional. Inline keyboard attached to the message
*
@ -226,6 +419,19 @@
return $this->reply_markup;
}
/**
* Sets the value of the 'reply_markup' field.
* Optional. Inline keyboard attached to the message
*
* @param InlineKeyboardMarkup|null $reply_markup
* @return $this
*/
public function setReplyMarkup(?InlineKeyboardMarkup $reply_markup): InlineQueryResultGif
{
$this->reply_markup = $reply_markup;
return $this;
}
/**
* Optional. Content of the message to be sent instead of the GIF animation
*
@ -236,6 +442,19 @@
return $this->input_message_content;
}
/**
* Sets the value of the 'input_message_content' field.
* Optional. Content of the message to be sent instead of the GIF animation
*
* @param InputVenueMessageContent|InputTextMessageContent|InputContactMessageContent|InputLocationMessageContent|InputInvoiceMessageContent|null $input_message_content
* @return $this
*/
public function setInputMessageContent(InputVenueMessageContent|InputTextMessageContent|InputContactMessageContent|InputLocationMessageContent|InputInvoiceMessageContent|null $input_message_content): InlineQueryResultGif
{
$this->input_message_content = $input_message_content;
return $this;
}
/**
* Returns an array representation of the object

View file

@ -4,7 +4,7 @@
namespace TgBotLib\Objects\Telegram\InputMedia;
use TgBotLib\Abstracts\InputMediaType;
use TgBotLib\Enums\InputMediaType;
use TgBotLib\Interfaces\ObjectTypeInterface;
use TgBotLib\Objects\Telegram\InputMedia;
use TgBotLib\Objects\Telegram\MessageEntity;
@ -208,7 +208,7 @@
public static function fromArray(array $data): self
{
$object = new static();
$object->type = $data['type'] ?? InputMediaType::Animation;
$object->type = $data['type'] ?? InputMediaType::ANIMATION;
$object->media = $data['media'] ?? null;
$object->thumb = $data['thumb'] ?? null;
$object->caption = $data['caption'] ?? null;

View file

@ -4,7 +4,7 @@
namespace TgBotLib\Objects\Telegram;
use TgBotLib\Abstracts\StickerType;
use TgBotLib\Enums\StickerType;
use TgBotLib\Interfaces\ObjectTypeInterface;
class StickerSet implements ObjectTypeInterface