Code fixes in \TgBotLib\Objects\Telegram\InlineQueryResult > InlineQueryResultPhoto
This commit is contained in:
parent
a1ec9fdb13
commit
77ce3969aa
1 changed files with 160 additions and 5 deletions
|
@ -1,9 +1,11 @@
|
|||
<?php
|
||||
|
||||
/** @noinspection PhpUnused */
|
||||
/** @noinspection PhpMissingFieldTypeInspection */
|
||||
|
||||
namespace TgBotLib\Objects\Telegram\InlineQueryResult;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use TgBotLib\Interfaces\ObjectTypeInterface;
|
||||
use TgBotLib\Objects\Telegram\InlineKeyboardMarkup;
|
||||
use TgBotLib\Objects\Telegram\InputMessageContent\InputContactMessageContent;
|
||||
|
@ -89,7 +91,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* Type of the result, must be photo
|
||||
* Type of the result must be photo
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
|
@ -108,6 +110,23 @@
|
|||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the 'id' field
|
||||
*
|
||||
* @param string $id
|
||||
* @return $this
|
||||
*/
|
||||
public function setId(string $id): InlineQueryResultPhoto
|
||||
{
|
||||
if(mb_strlen($id) > 64)
|
||||
{
|
||||
throw new InvalidArgumentException('id length must not exceed 64 characters');
|
||||
}
|
||||
|
||||
$this->id = $id;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* A valid URL of the photo. Photo must be in JPEG format. Photo size must not exceed 5MB
|
||||
*
|
||||
|
@ -118,6 +137,18 @@
|
|||
return $this->photo_url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the 'photo_url' field
|
||||
*
|
||||
* @param string $photo_url
|
||||
* @return $this
|
||||
*/
|
||||
public function setPhotoUrl(string $photo_url): InlineQueryResultPhoto
|
||||
{
|
||||
$this->photo_url = $photo_url;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* URL of the thumbnail for the photo
|
||||
*
|
||||
|
@ -128,6 +159,23 @@
|
|||
return $this->thumbnail_url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the 'thumbnail_url' field
|
||||
*
|
||||
* @param string $thumbnail_url
|
||||
* @return $this
|
||||
*/
|
||||
public function setThumbnailUrl(string $thumbnail_url): InlineQueryResultPhoto
|
||||
{
|
||||
if(!filter_var($thumbnail_url, FILTER_VALIDATE_URL))
|
||||
{
|
||||
throw new InvalidArgumentException('thumbnail_url must be a valid URL');
|
||||
}
|
||||
|
||||
$this->thumbnail_url = $thumbnail_url;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Optional. Width of the photo
|
||||
*
|
||||
|
@ -138,6 +186,18 @@
|
|||
return $this->photo_width;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the 'photo_width' field
|
||||
*
|
||||
* @param int|null $photo_width
|
||||
* @return $this
|
||||
*/
|
||||
public function setPhotoWidth(?int $photo_width): InlineQueryResultPhoto
|
||||
{
|
||||
$this->photo_width = $photo_width;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Optional. Height of the photo
|
||||
*
|
||||
|
@ -148,6 +208,18 @@
|
|||
return $this->photo_height;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the 'photo_height' field
|
||||
*
|
||||
* @param int|null $photo_height
|
||||
* @return $this
|
||||
*/
|
||||
public function setPhotoHeight(?int $photo_height): InlineQueryResultPhoto
|
||||
{
|
||||
$this->photo_height = $photo_height;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Optional. Title for the result
|
||||
*
|
||||
|
@ -158,6 +230,18 @@
|
|||
return $this->title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the 'title' field
|
||||
*
|
||||
* @param string|null $title
|
||||
* @return $this
|
||||
*/
|
||||
public function setTitle(?string $title): InlineQueryResultPhoto
|
||||
{
|
||||
$this->title = $title;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Optional. Short description of the result
|
||||
*
|
||||
|
@ -168,6 +252,18 @@
|
|||
return $this->description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the 'description' field
|
||||
*
|
||||
* @param string|null $description
|
||||
* @return $this
|
||||
*/
|
||||
public function setDescription(?string $description): InlineQueryResultPhoto
|
||||
{
|
||||
$this->description = $description;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Optional. Caption of the photo to be sent, 0-1024 characters after entities parsing
|
||||
*
|
||||
|
@ -178,6 +274,18 @@
|
|||
return $this->caption;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the 'caption' field
|
||||
*
|
||||
* @param string|null $caption
|
||||
* @return $this
|
||||
*/
|
||||
public function setCaption(?string $caption): InlineQueryResultPhoto
|
||||
{
|
||||
$this->caption = $caption;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Optional. Mode for parsing entities in the photo caption. See formatting options for more details.
|
||||
*
|
||||
|
@ -189,6 +297,18 @@
|
|||
return $this->parse_mode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the 'parse_mode' field
|
||||
*
|
||||
* @param string|null $parse_mode
|
||||
* @return $this
|
||||
*/
|
||||
public function setParseMode(?string $parse_mode): InlineQueryResultPhoto
|
||||
{
|
||||
$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
|
||||
*
|
||||
|
@ -199,6 +319,18 @@
|
|||
return $this->caption_entities;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the 'caption_entities' field
|
||||
*
|
||||
* @param array|null $caption_entities
|
||||
* @return $this
|
||||
*/
|
||||
public function setCaptionEntities(?array $caption_entities): InlineQueryResultPhoto
|
||||
{
|
||||
$this->caption_entities = $caption_entities;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Optional. Inline keyboard attached to the message
|
||||
*
|
||||
|
@ -209,6 +341,18 @@
|
|||
return $this->reply_markup;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the 'reply_markup' field
|
||||
*
|
||||
* @param InlineKeyboardMarkup|null $reply_markup
|
||||
* @return $this
|
||||
*/
|
||||
public function setReplyMarkup(?InlineKeyboardMarkup $reply_markup): InlineQueryResultPhoto
|
||||
{
|
||||
$this->reply_markup = $reply_markup;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Optional. Content of the message to be sent instead of the photo
|
||||
*
|
||||
|
@ -219,6 +363,18 @@
|
|||
return $this->input_message_content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the 'input_message_content' field
|
||||
*
|
||||
* @param InputVenueMessageContent|InputTextMessageContent|InputContactMessageContent|InputLocationMessageContent|InputInvoiceMessageContent|null $input_message_content
|
||||
* @return $this
|
||||
*/
|
||||
public function setInputMessageContent(InputVenueMessageContent|InputTextMessageContent|InputContactMessageContent|InputLocationMessageContent|InputInvoiceMessageContent|null $input_message_content): InlineQueryResultPhoto
|
||||
{
|
||||
$this->input_message_content = $input_message_content;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array representation of the object
|
||||
*
|
||||
|
@ -237,7 +393,7 @@
|
|||
'description' => $this->description ?? null,
|
||||
'caption' => $this->caption ?? null,
|
||||
'parse_mode' => $this->parse_mode ?? null,
|
||||
'caption_entities' => ($this->caption_entities !== null) ? array_map(function (MessageEntity $messageEntity) {
|
||||
'caption_entities' => ($this->caption_entities !== null) ? array_map(static function (MessageEntity $messageEntity) {
|
||||
return $messageEntity->toArray();
|
||||
}, $this->caption_entities) : null,
|
||||
'reply_markup' => ($this->reply_markup instanceof InlineKeyboardMarkup) ? $this->reply_markup->toArray() : null,
|
||||
|
@ -245,7 +401,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* Constructs object from an array representation
|
||||
* Constructs an object from an array representation
|
||||
*
|
||||
* @param array $data
|
||||
* @return ObjectTypeInterface
|
||||
|
@ -264,8 +420,7 @@
|
|||
$object->description = $data['description'] ?? null;
|
||||
$object->caption = $data['caption'] ?? null;
|
||||
$object->parse_mode = $data['parse_mode'] ?? null;
|
||||
$object->caption_entities = ($data['caption_entities'] !== null) ? array_map(function (array $messageEntity)
|
||||
{
|
||||
$object->caption_entities = ($data['caption_entities'] !== null) ? array_map(static function (array $messageEntity) {
|
||||
return MessageEntity::fromArray($messageEntity);
|
||||
}, $data['caption_entities']) : null;
|
||||
$object->reply_markup = ($data['reply_markup'] !== null) ? InlineKeyboardMarkup::fromArray($data['reply_markup']) : null;
|
||||
|
|
Loading…
Add table
Reference in a new issue