Initial ugly commit of the refactored Entities.

parent ae619a1b
......@@ -10,122 +10,19 @@
namespace Longman\TelegramBot\Entities;
use Longman\TelegramBot\Exception\TelegramException;
/**
* Class Audio
*
* @link https://core.telegram.org/bots/api#audio
*
* @method string getFileId() Unique identifier for this file
* @method int getDuration() Duration of the audio in seconds as defined by sender
* @method string getPerformer() Optional. Performer of the audio as defined by sender or by audio tags
* @method string getTitle() Optional. Title of the audio as defined by sender or by audio tags
* @method string getMimeType() Optional. MIME type of the file as defined by sender
* @method int getFileSize() Optional. File size
*/
class Audio extends Entity
{
/**
* @var mixed|null
*/
protected $file_id;
/**
* @var mixed|null
*/
protected $duration;
/**
* @var mixed|null
*/
protected $performer;
/**
* @var mixed|null
*/
protected $title;
/**
* @var mixed|null
*/
protected $mime_type;
/**
* @var mixed|null
*/
protected $file_size;
/**
* Audio constructor.
*
* @param array $data
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function __construct(array $data)
{
$this->file_id = isset($data['file_id']) ? $data['file_id'] : null;
if (empty($this->file_id)) {
throw new TelegramException('file_id is empty!');
}
$this->duration = isset($data['duration']) ? $data['duration'] : null;
if ($this->duration === '' || $this->duration === null) {
throw new TelegramException('duration is empty!');
}
$this->performer = isset($data['performer']) ? $data['performer'] : null;
$this->title = isset($data['title']) ? $data['title'] : null;
$this->mime_type = isset($data['mime_type']) ? $data['mime_type'] : null;
$this->file_size = isset($data['file_size']) ? $data['file_size'] : null;
}
/**
* Get file id
*
* @return mixed|null
*/
public function getFileId()
{
return $this->file_id;
}
/**
* Get duration
*
* @return mixed|null
*/
public function getDuration()
{
return $this->duration;
}
/**
* Get performer
*
* @return mixed|null
*/
public function getPerformer()
{
return $this->performer;
}
/**
* Get title
*
* @return mixed|null
*/
public function getTitle()
{
return $this->title;
}
/**
* Get mime type
*
* @return mixed|null
*/
public function getMimeType()
{
return $this->mime_type;
}
/**
* Get file size
*
* @return mixed|null
*/
public function getFileSize()
{
return $this->file_size;
}
}
......@@ -10,114 +10,27 @@
namespace Longman\TelegramBot\Entities;
use Longman\TelegramBot\Exception\TelegramException;
/**
* Class CallbackQuery.
*
* @link https://core.telegram.org/bots/api#callbackquery
*
* @method string getId() Unique identifier for this query
* @method User getFrom() Sender
* @method Message getMessage() Optional. Message with the callback button that originated the query. Note that message content and message date will not be available if the message is too old
* @method string getInlineMessageId() Optional. Identifier of the message sent via the bot in inline mode, that originated the query
* @method string getData() Data associated with the callback button. Be aware that a bad client can send arbitrary data in this field
*/
class CallbackQuery extends Entity
{
/**
* @var mixed|null
*/
protected $id;
/**
* @var \Longman\TelegramBot\Entities\User
*/
protected $from;
/**
* @var \Longman\TelegramBot\Entities\Message
*/
protected $message;
/**
* @var mixed|null
*/
protected $inline_message_id;
/**
* @var mixed|null
*/
protected $data;
/**
* CallbackQuery constructor.
*
* @param array $data
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function __construct(array $data)
{
$this->id = isset($data['id']) ? $data['id'] : null;
if (empty($this->id)) {
throw new TelegramException('id is empty!');
}
$this->from = isset($data['from']) ? $data['from'] : null;
if (empty($this->from)) {
throw new TelegramException('from is empty!');
}
$this->from = new User($this->from);
$this->message = isset($data['message']) ? $data['message'] : null;
if (!empty($this->message)) {
$this->message = new Message($this->message, $this->getBotName());
}
$this->inline_message_id = isset($data['inline_message_id']) ? $data['inline_message_id'] : null;
$this->data = isset($data['data']) ? $data['data'] : null;
if (empty($this->data)) {
throw new TelegramException('data is empty!');
}
}
/**
* Get id
*
* @return mixed|null
*/
public function getId()
{
return $this->id;
}
/**
* Get from
*
* @return \Longman\TelegramBot\Entities\User
*/
public function getFrom()
{
return $this->from;
}
/**
* Get message
*
* @return \Longman\TelegramBot\Entities\Message
*/
public function getMessage()
{
return $this->message;
}
/**
* Get inline message id
*
* @return mixed|null
*/
public function getInlineMessageId()
{
return $this->inline_message_id;
}
/**
* Get data
*
* @return mixed|null
* {@inheritdoc}
*/
public function getData()
public function subEntities()
{
return $this->data;
return [
'from' => User::class,
'message' => Message::class,
];
}
}
......@@ -10,198 +10,98 @@
namespace Longman\TelegramBot\Entities;
use Longman\TelegramBot\Exception\TelegramException;
/**
* Class Chat
*
* @link https://core.telegram.org/bots/api#chat
*
* @property int $id Unique identifier for this chat. This number may be greater than 32 bits and some programming languages may have difficulty/silent defects in interpreting it. But it smaller than 52 bits, so a signed 64 bit integer or double-precision float type are safe for storing this identifier.
* @property string $type Type of chat, can be either "private", "group", "supergroup" or "channel"
* @property string $title Optional. Title, for channels and group chats
* @property string $username Optional. Username, for private chats, supergroups and channels if available
* @property string $first_name Optional. First name of the other party in a private chat
* @property string $last_name Optional. Last name of the other party in a private chat
* @method int getId() Unique identifier for this chat. This number may be greater than 32 bits and some programming languages may have difficulty/silent defects in interpreting it. But it smaller than 52 bits, so a signed 64 bit integer or double-precision float type are safe for storing this identifier.
* @method string getType() Type of chat, can be either "private ", "group", "supergroup" or "channel"
* @method string getTitle() Optional. Title, for channels and group chats
* @method string getUsername() Optional. Username, for private chats, supergroups and channels if available
* @method string getFirstName() Optional. First name of the other party in a private chat
* @method string getLastName() Optional. Last name of the other party in a private chat
*/
class Chat extends Entity
{
/**
* @var mixed|null
*/
protected $id;
/**
* @var null
*/
protected $type;
/**
* @var mixed|null
*/
protected $title;
/**
* @var mixed|null
*/
protected $username;
/**
* @var mixed|null
*/
protected $first_name;
public function __construct($data)
{
parent::__construct($data);
/**
* @var mixed|null
*/
protected $last_name;
if (!$this->getType()) {
if ($this->getId() > 0) {
$this->type = 'private';
} elseif ($this->getId() < 0) {
$this->type = 'group';
}
}
}
/**
* Chat constructor.
* Try mention
*
* @param array $data
* @throws \Longman\TelegramBot\Exception\TelegramException
* @return string|null
*/
public function __construct(array $data)
public function tryMention()
{
$this->id = isset($data['id']) ? $data['id'] : null;
if (empty($this->id)) {
throw new TelegramException('id is empty!');
}
if ($this->isPrivateChat()) {
if ($this->username === null) {
if ($this->last_name !== null) {
return $this->first_name . ' ' . $this->last_name;
}
if (isset($data['type'])) {
$this->type = $data['type'];
} else {
if ($this->id > 0) {
$this->type = 'private';
} elseif ($this->id < 0) {
$this->type = 'group';
} else {
$this->type = null;
return $this->first_name;
}
return '@' . $this->username;
}
$this->title = isset($data['title']) ? $data['title'] : null;
$this->first_name = isset($data['first_name']) ? $data['first_name'] : null;
$this->last_name = isset($data['last_name']) ? $data['last_name'] : null;
$this->username = isset($data['username']) ? $data['username'] : null;
return $this->getTitle();
}
/**
* Check if is group chat
* Check if this is a group chat
*
* @return bool
*/
public function isGroupChat()
{
if ($this->type == 'group' || $this->id < 0) {
return true;
}
return false;
return $this->type === 'group' || $this->id < 0;
}
/**
* Check if is private chat
* Check if this is a private chat
*
* @return bool
*/
public function isPrivateChat()
{
if ($this->type == 'private') {
return true;
}
return false;
return $this->type === 'private';
}
/**
* Check if is super group
* Check if this is a super group
*
* @return bool
*/
public function isSuperGroup()
{
if ($this->type == 'supergroup') {
return true;
}
return false;
return $this->type === 'supergroup';
}
/**
* Check if is channel
* Check if this is a channel
*
* @return bool
*/
public function isChannel()
{
if ($this->type == 'channel') {
return true;
}
return false;
}
/**
* Get id
*
* @return mixed|null
*/
public function getId()
{
return $this->id;
}
/**
* Get type
*
* @return null
*/
public function getType()
{
return $this->type;
}
/**
* Get title
*
* @return mixed|null
*/
public function getTitle()
{
return $this->title;
}
/**
* Get first name
*
* @return mixed|null
*/
public function getFirstName()
{
return $this->first_name;
}
/**
* Get last name
*
* @return mixed|null
*/
public function getLastName()
{
return $this->last_name;
}
/**
* Get username
*
* @return mixed|null
*/
public function getUsername()
{
return $this->username;
}
/**
* Try mention
*
* @return mixed|null|string
*/
public function tryMention()
{
if ($this->isPrivateChat()) {
if (is_null($this->username)) {
if (!is_null($this->last_name)) {
return $this->first_name . ' ' . $this->last_name;
}
return $this->first_name;
}
return '@' . $this->username;
}
return $this->getTitle();
return $this->type === 'channel';
}
}
......@@ -10,57 +10,23 @@
namespace Longman\TelegramBot\Entities;
use Longman\TelegramBot\Exception\TelegramException;
/**
* Class ChatMember
*
* @link https://core.telegram.org/bots/api#chatmember
*
* @method User getUser() Information about the user.
* @method string getStatus() The member's status in the chat. Can be "creator", "administrator", "member", "left" or "kicked"
*/
class ChatMember extends Entity
{
/**
* @var \Longman\TelegramBot\Entities\User
*/
protected $user;
/**
* @var mixed|null
*/
protected $status;
/**
* ChatMember constructor.
*
* @param array $data
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function __construct(array $data)
{
$this->user = isset($data['user']) ? $data['user'] : null;
if (empty($this->user)) {
throw new TelegramException('user is empty!');
}
$this->user = new User($data['user']);
$this->status = isset($data['status']) ? $data['status'] : null;
if ($this->status === '') {
throw new TelegramException('status is empty!');
}
}
/**
* Get user
*
* @return \Longman\TelegramBot\Entities\User
*/
public function getUser()
{
return $this->user;
}
/**
* Get status
*
* @return mixed|null
* {@inheritdoc}
*/
public function getStatus()
public function subEntities()
{
return $this->status;
return [
'user' => User::class,
];
}
}
......@@ -10,110 +10,27 @@
namespace Longman\TelegramBot\Entities;
use Longman\TelegramBot\Exception\TelegramException;
/**
* Class ChosenInlineResult
*
* @link https://core.telegram.org/bots/api#choseninlineresult
*
* @method string getResultId() The unique identifier for the result that was chosen
* @method User getFrom() The user that chose the result
* @method Location getLocation() Optional. Sender location, only for bots that require user location
* @method string getInlineMessageId() Optional. Identifier of the sent inline message. Available only if there is an inline keyboard attached to the message. Will be also received in callback queries and can be used to edit the message.
* @method string getQuery() The query that was used to obtain the result
*/
class ChosenInlineResult extends Entity
{
/**
* @var mixed|null
*/
protected $result_id;
/**
* @var \Longman\TelegramBot\Entities\User
*/
protected $from;
/**
* @var \Longman\TelegramBot\Entities\Location
*/
protected $location;
/**
* @var mixed|null
*/
protected $inline_message_id;
/**
* @var mixed|null
*/
protected $query;
/**
* ChosenInlineResult constructor.
*
* @param array $data
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function __construct(array $data)
{
$this->result_id = isset($data['result_id']) ? $data['result_id'] : null;
if (empty($this->result_id)) {
throw new TelegramException('result_id is empty!');
}
$this->from = isset($data['from']) ? $data['from'] : null;
if (empty($this->from)) {
throw new TelegramException('from is empty!');
}
$this->from = new User($this->from);
$this->location = isset($data['location']) ? $data['location'] : null;
if (!empty($this->location)) {
$this->location = new Location($this->location);
}
$this->inline_message_id = isset($data['inline_message_id']) ? $data['inline_message_id'] : null;
$this->query = isset($data['query']) ? $data['query'] : null;
}
/**
* Ger result id
*
* @return mixed|null
*/
public function getResultId()
{
return $this->result_id;
}
/**
* Get from
*
* @return \Longman\TelegramBot\Entities\User
*/
public function getFrom()
{
return $this->from;
}
/**
* Get location
*
* @return \Longman\TelegramBot\Entities\Location
*/
public function getLocation()
{
return $this->location;
}
/**
* Get inline message id
*
* @return mixed|null
*/
public function getInlineMessageId()
{
return $this->inline_message_id;
}
/**
* Get query
*
* @return mixed|null
* {@inheritdoc}
*/
public function getQuery()
protected function subEntities()
{
return $this->query;
return [
'from' => User::class,
'location' => Location::class,
];
}
}
......@@ -10,89 +10,17 @@
namespace Longman\TelegramBot\Entities;
use Longman\TelegramBot\Exception\TelegramException;
/**
* Class Contact
*
* @link https://core.telegram.org/bots/api#contact
*
* @method string getPhoneNumber() Contact's phone number
* @method string getFirstName() Contact's first name
* @method string getLastName() Optional. Contact's last name
* @method int getUserId() Optional. Contact's user identifier in Telegram
*/
class Contact extends Entity
{
/**
* @var mixed|null
*/
protected $phone_number;
/**
* @var mixed|null
*/
protected $first_name;
/**
* @var mixed|null
*/
protected $last_name;
/**
* @var mixed|null
*/
protected $user_id;
/**
* Contact constructor.
*
* @param array $data
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function __construct(array $data)
{
$this->phone_number = isset($data['phone_number']) ? $data['phone_number'] : null;
if (empty($this->phone_number)) {
throw new TelegramException('phone_number is empty!');
}
$this->first_name = isset($data['first_name']) ? $data['first_name'] : null;
if (empty($this->first_name)) {
throw new TelegramException('first_name is empty!');
}
$this->last_name = isset($data['last_name']) ? $data['last_name'] : null;
$this->user_id = isset($data['user_id']) ? $data['user_id'] : null;
}
/**
* Get phone number
*
* @return mixed|null
*/
public function getPhoneNumber()
{
return $this->phone_number;
}
/**
* Get first name
*
* @return mixed|null
*/
public function getFirstName()
{
return $this->first_name;
}
/**
* Get last name
*
* @return mixed|null
*/
public function getLastName()
{
return $this->last_name;
}
/**
* Get user id
*
* @return mixed|null
*/
public function getUserId()
{
return $this->user_id;
}
}
......@@ -10,105 +10,26 @@
namespace Longman\TelegramBot\Entities;
use Longman\TelegramBot\Exception\TelegramException;
/**
* Class Document
*
* @link https://core.telegram.org/bots/api#document
*
* @method string getFileId() Unique file identifier
* @method PhotoSize getThumb() Optional. Document thumbnail as defined by sender
* @method string getFileName() Optional. Original filename as defined by sender
* @method string getMimeType() Optional. MIME type of the file as defined by sender
* @method int getFileSize() Optional. File size
*/
class Document extends Entity
{
/**
* @var mixed|null
*/
protected $file_id;
/**
* @var \Longman\TelegramBot\Entities\PhotoSize
*/
protected $thumb;
/**
* @var mixed|null
*/
protected $file_name;
/**
* @var mixed|null
*/
protected $mime_type;
/**
* @var mixed|null
*/
protected $file_size;
/**
* Document constructor.
*
* @param array $data
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function __construct(array $data)
{
$this->file_id = isset($data['file_id']) ? $data['file_id'] : null;
if (empty($this->file_id)) {
throw new TelegramException('file_id is empty!');
}
$this->thumb = isset($data['thumb']) ? $data['thumb'] : null;
if (!empty($this->thumb)) {
$this->thumb = new PhotoSize($this->thumb);
}
$this->file_name = isset($data['file_name']) ? $data['file_name'] : null;
$this->mime_type = isset($data['mime_type']) ? $data['mime_type'] : null;
$this->file_size = isset($data['file_size']) ? $data['file_size'] : null;
}
/**
* Get file id
*
* @return mixed|null
*/
public function getFileId()
{
return $this->file_id;
}
/**
* Get thumb
*
* @return \Longman\TelegramBot\Entities\PhotoSize
*/
public function getThumb()
{
return $this->thumb;
}
/**
* Get file name
*
* @return mixed|null
*/
public function getFileName()
{
return $this->file_name;
}
/**
* Get mime type
*
* @return mixed|null
*/
public function getMimeType()
{
return $this->mime_type;
}
/**
* Get file size
*
* @return mixed|null
* {@inheritdoc}
*/
public function getFileSize()
protected function subEntities()
{
return $this->file_size;
return [
'thumb' => PhotoSize::class,
];
}
}
......@@ -10,7 +10,10 @@
namespace Longman\TelegramBot\Entities;
class InputMessageContent extends Entity
/**
* {@inheritdoc}
*/
class EditedMessage extends Message
{
}
......@@ -10,8 +10,14 @@
namespace Longman\TelegramBot\Entities;
use Exception;
use ReflectionObject;
/**
* Class Entity
*
* This is the base class for all entities.
*/
class Entity
{
/**
......@@ -29,6 +35,23 @@ class Entity
return $this->bot_name;
}
/**
* Entity constructor.
*
* @todo Get rid of the $bot_name, it shouldn't be here!
*
* @param $data
* @param string $bot_name
*
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function __construct($data, $bot_name = '')
{
$this->assignMemberVariables($data);
$this->validate();
$this->bot_name = $bot_name;
}
/**
* Perform to json
*
......@@ -36,21 +59,19 @@ class Entity
*/
public function toJson()
{
$fields = $this->reflect($this);
$json = json_encode($fields);
return $json;
return json_encode($this->reflect($this));
}
/**
* Reflect
*
* @param null $object
*
* @return array
*/
public function reflect($object = null)
{
if ($object == null) {
if ($object === null) {
$object = $this;
}
......@@ -61,7 +82,7 @@ class Entity
foreach ($properties as $property) {
$name = $property->getName();
if ($name == 'bot_name') {
if ($name === 'bot_name') {
continue;
}
......@@ -107,13 +128,14 @@ class Entity
} else {
$property->setAccessible(true);
$value = $property->getValue($object);
if (is_null($value)) {
if (null === $value) {
continue;
}
$fields[$name] = $value;
}
}
}
return $fields;
}
......@@ -126,4 +148,113 @@ class Entity
{
return $this->toJson();
}
/**
* Helper to set member variables
*
* @param array $data
*/
protected function assignMemberVariables(array $data)
{
foreach ($data as $key => $value) {
$this->$key = $value;
}
}
/**
* Get the list of the properties that are themselves Entities
*
* @return array
*/
protected function subEntities()
{
return [];
}
/**
* Perform any special entity validation
*
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
protected function validate()
{
}
/**
* Get a property from the current Entity
*
* @param mixed $property
* @param mixed $default
*
* @return mixed
*/
public function getProperty($property, $default = null)
{
if (isset($this->$property)) {
return $this->$property;
}
return $default;
}
/**
* Return the variable for the called getter
*
* @param $method
* @param $args
*
* @return mixed|null
*/
public function __call($method, $args)
{
$action = substr($method, 0, 3);
if ($action === 'get') {
//Convert method to snake_case (which is the name of the property)
$property_name = ltrim(strtolower(preg_replace('/[A-Z]/', '_$0', substr($method, 3))), '_');
$property = $this->getProperty($property_name);
if ($property !== null) {
//Get all sub-Entities of the current Entity
$sub_entities = $this->subEntities();
if (isset($sub_entities[$property_name])) {
return new $sub_entities[$property_name]($property);
}
return $property;
}
}
return null;
}
/**
* Return an array of nice objects from an array of object arrays
*
* This method is used to generate pretty object arrays
* mainly for PhotoSize and Entities object arrays.
*
* @param string $class
* @param string $property
*
* @return array
*/
protected function makePrettyObjectArray($class, $property)
{
$new_objects = [];
try {
if ($objects = $this->getProperty($property)) {
foreach ($objects as $object) {
if (!empty($object)) {
$new_objects[] = new $class($object);
}
}
}
} catch (Exception $e) {
$new_objects = [];
}
return $new_objects;
}
}
......@@ -10,70 +10,16 @@
namespace Longman\TelegramBot\Entities;
use Longman\TelegramBot\Exception\TelegramException;
/**
* Class File
*
* @link https://core.telegram.org/bots/api#file
*
* @method string getFileId() Unique identifier for this file
* @method int getFileSize() Optional. File size, if known
* @method string getFilePath() Optional. File path. Use https://api.telegram.org/file/bot<token>/<file_path> to get the file.
*/
class File extends Entity
{
/**
* @var mixed|null
*/
protected $file_id;
/**
* @var mixed|null
*/
protected $file_size;
/**
* @var mixed|null
*/
protected $file_path;
/**
* File constructor.
*
* @param array $data
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function __construct(array $data)
{
$this->file_id = isset($data['file_id']) ? $data['file_id'] : null;
if (empty($this->file_id)) {
throw new TelegramException('file_id is empty!');
}
$this->file_size = isset($data['file_size']) ? $data['file_size'] : null;
$this->file_path = isset($data['file_path']) ? $data['file_path'] : null;
}
/**
* Get file id
*
* @return mixed|null
*/
public function getFileId()
{
return $this->file_id;
}
/**
* Get file size
*
* @return mixed|null
*/
public function getFileSize()
{
return $this->file_size;
}
/**
* Get file path
*
* @return mixed|null
*/
public function getFilePath()
{
return $this->file_path;
}
}
......@@ -12,45 +12,26 @@ namespace Longman\TelegramBot\Entities;
use Longman\TelegramBot\Exception\TelegramException;
/**
* Class InlineKeyboardButton
*
* @link https://core.telegram.org/bots/api#inlinekeyboardbutton
*
* @method string getText() Label text on the button
* @method string getUrl() Optional. HTTP url to be opened when button is pressed
* @method string getCallbackData() Optional. Data to be sent in a callback query to the bot when button is pressed, 1-64 bytes
* @method string getSwitchInlineQuery() Optional. If set, pressing the button will prompt the user to select one of their chats, open that chat and insert the bot's username and the specified inline query in the input field. Can be empty, in which case just the bot’s username will be inserted.
*/
class InlineKeyboardButton extends Entity
{
/**
* @var mixed|null
*/
protected $text;
/**
* @var string
*/
protected $url;
/**
* @var mixed
* {@inheritdoc}
*/
protected $callback_data;
/**
* @var mixed
*/
protected $switch_inline_query;
/**
* InlineKeyboardButton constructor.
*
* @param array $data
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function __construct(array $data = [])
protected function validate()
{
$this->text = isset($data['text']) ? $data['text'] : null;
if (empty($this->text)) {
throw new TelegramException('text is empty!');
}
$num_params = 0;
foreach (['url', 'callback_data', 'switch_inline_query'] as $param) {
if (!empty($data[$param])) {
$this->$param = $data[$param];
if (!empty($this->getProperty($param))) {
$num_params++;
}
}
......
......@@ -12,6 +12,11 @@ namespace Longman\TelegramBot\Entities;
use Longman\TelegramBot\Exception\TelegramException;
/**
* Class InlineKeyboardMarkup
*
* @link https://core.telegram.org/bots/api#inlinekeyboardmarkup
*/
class InlineKeyboardMarkup extends Entity
{
/**
......
......@@ -10,110 +10,27 @@
namespace Longman\TelegramBot\Entities;
use Longman\TelegramBot\Exception\TelegramException;
/**
* Class InlineQuery
*
* @link https://core.telegram.org/bots/api#inlinequery
*
* @method string getId() Unique identifier for this query
* @method User getFrom() Sender
* @method Location getLocation() Optional. Sender location, only for bots that request user location
* @method string getQuery() Text of the query (up to 512 characters)
* @method string getOffset() Offset of the results to be returned, can be controlled by the bot
*/
class InlineQuery extends Entity
{
/**
* @var mixed|null
*/
protected $id;
/**
* @var \Longman\TelegramBot\Entities\User
*/
protected $from;
/**
* @var \Longman\TelegramBot\Entities\Location
*/
protected $location;
/**
* @var mixed|null
*/
protected $query;
/**
* @var mixed|null
*/
protected $offset;
/**
* InlineQuery constructor.
*
* @param array $data
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function __construct(array $data)
{
$this->id = isset($data['id']) ? $data['id'] : null;
if (empty($this->id)) {
throw new TelegramException('id is empty!');
}
$this->from = isset($data['from']) ? $data['from'] : null;
if (empty($this->from)) {
throw new TelegramException('from is empty!');
}
$this->from = new User($this->from);
$this->location = isset($data['location']) ? $data['location'] : null;
if (!empty($this->location)) {
$this->location = new Location($this->location);
}
$this->query = isset($data['query']) ? $data['query'] : null;
$this->offset = isset($data['offset']) ? $data['offset'] : null;
}
/**
* Get id
*
* @return mixed|null
*/
public function getId()
{
return $this->id;
}
/**
* Get from
*
* @return \Longman\TelegramBot\Entities\User
*/
public function getFrom()
{
return $this->from;
}
/**
* Get location
*
* @return \Longman\TelegramBot\Entities\Location
*/
public function getLocation()
{
return $this->location;
}
/**
* Get query
*
* @return mixed|null
*/
public function getQuery()
{
return $this->query;
}
/**
* Get offset
*
* @return mixed|null
* {@inheritdoc}
*/
public function getOffset()
protected function subEntities()
{
return $this->offset;
return [
'from' => User::class,
'location' => Location::class,
];
}
}
<?php
/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Longman\TelegramBot\Entities\InlineQuery;
use Longman\TelegramBot\Entities\Entity;
abstract class InlineEntity extends Entity
{
/**
* Magic method to set properties dynamically
*
* @param $method
* @param $args
*
* @return \Longman\TelegramBot\Entities\InlineQuery\InlineEntity
*/
public function __call($method, $args)
{
$action = substr($method, 0, 3);
if ($action === 'set') {
//Convert method to snake_case (which is the name of the property)
$property_name = ltrim(strtolower(preg_replace('/[A-Z]/', '_$0', substr($method, 3))), '_');
$this->$property_name = $args[0];
}
return $this;
}
}
<?php
/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Longman\TelegramBot\Entities\InlineQuery;
use Longman\TelegramBot\Entities\InlineKeyboardMarkup;
use Longman\TelegramBot\Entities\InputMessageContent\InputMessageContent;
/**
* Class InlineQueryResultArticle
*
* @link https://core.telegram.org/bots/api#inlinequeryresultarticle
*
* <code>
* $data = [
* 'id' => '',
* 'title' => '',
* 'input_message_content' => <InputMessageContent>,
* 'reply_markup' => <InlineKeyboardMarkup>,
* 'url' => '',
* 'hide_url' => true,
* 'description' => '',
* 'thumb_url' => '',
* 'thumb_width' => 30,
* 'thumb_height' => 30,
* ];
* </code>
*
* @method string getType() Type of the result, must be article
* @method string getId() Unique identifier for this result, 1-64 Bytes
* @method string getTitle() Title of the result
* @method InputMessageContent getInputMessageContent() Content of the message to be sent
* @method InlineKeyboardMarkup getReplyMarkup() Optional. Inline keyboard attached to the message
* @method string getUrl() Optional. URL of the result
* @method bool getHideUrl() Optional. Pass True, if you don't want the URL to be shown in the message
* @method string getDescription() Optional. Short description of the result
* @method string getThumbUrl() Optional. Url of the thumbnail for the result
* @method int getThumbWidth() Optional. Thumbnail width
* @method int getThumbHeight() Optional. Thumbnail height
*
* @method $this setId(string $id) Unique identifier for this result, 1-64 Bytes
* @method $this setTitle(string $title) Title of the result
* @method $this setInputMessageContent(InputMessageContent $input_message_content) Content of the message to be sent
* @method $this setReplyMarkup(InlineKeyboardMarkup $reply_markup) Optional. Inline keyboard attached to the message
* @method $this setUrl(string $url) Optional. URL of the result
* @method $this setHideUrl(bool $hide_url) Optional. Pass True, if you don't want the URL to be shown in the message
* @method $this setDescription(string $description) Optional. Short description of the result
* @method $this setThumbUrl(string $thumb_url) Optional. Url of the thumbnail for the result
* @method $this setThumbWidth(int $thumb_width) Optional. Thumbnail width
* @method $this setThumbHeight(int $thumb_height) Optional. Thumbnail height
*/
class InlineQueryResultArticle extends InlineEntity
{
/**
* InlineQueryResultArticle constructor
*
* @param array $data
*
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function __construct(array $data = [])
{
$data['type'] = 'article';
parent::__construct($data);
}
}
<?php
/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Longman\TelegramBot\Entities\InlineQuery;
use Longman\TelegramBot\Entities\InlineKeyboardMarkup;
use Longman\TelegramBot\Entities\InputMessageContent\InputMessageContent;
/**
* Class InlineQueryResultAudio
*
* @link https://core.telegram.org/bots/api#inlinequeryresultaudio
*
* <code>
* $data = [
* 'id' => '',
* 'audio_url' => '',
* 'title' => '',
* 'performer' => '',
* 'audio_duration' => 123,
* 'reply_markup' => <InlineKeyboardMarkup>,
* 'input_message_content' => <InputMessageContent>,
* ];
* </code>
*
* @method string getType() Type of the result, must be audio
* @method string getId() Unique identifier for this result, 1-64 bytes
* @method string getAudioUrl() A valid URL for the audio file
* @method string getTitle() Title
* @method string getPerformer() Optional. Performer
* @method int getAudioDuration() Optional. Audio duration in seconds
* @method InlineKeyboardMarkup getReplyMarkup() Optional. Inline keyboard attached to the message
* @method InputMessageContent getInputMessageContent() Optional. Content of the message to be sent instead of the audio
*
* @method $this setId(string $id) Unique identifier for this result, 1-64 bytes
* @method $this setAudioUrl(string $audio_url) A valid URL for the audio file
* @method $this setTitle(string $title) Title
* @method $this setPerformer(string $performer) Optional. Performer
* @method $this setAudioDuration(int $audio_duration) Optional. Audio duration in seconds
* @method $this setReplyMarkup(InlineKeyboardMarkup $reply_markup) Optional. Inline keyboard attached to the message
* @method $this setInputMessageContent(InputMessageContent $input_message_content) Optional. Content of the message to be sent instead of the photo
*/
class InlineQueryResultAudio extends InlineEntity
{
/**
* InlineQueryResultAudio constructor
*
* @param array $data
*
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function __construct(array $data = [])
{
$data['type'] = 'audio';
parent::__construct($data);
}
}
<?php
/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Longman\TelegramBot\Entities\InlineQuery;
use Longman\TelegramBot\Entities\InlineKeyboardMarkup;
use Longman\TelegramBot\Entities\InputMessageContent\InputMessageContent;
/**
* Class InlineQueryResultCachedAudio
*
* @link https://core.telegram.org/bots/api#inlinequeryresultcachedaudio
*
* <code>
* $data = [
* 'id' => '',
* 'audio_file_id' => '',
* 'reply_markup' => <InlineKeyboardMarkup>,
* 'input_message_content' => <InputMessageContent>,
* ];
* </code>
*
* @method string getType() Type of the result, must be audio
* @method string getId() Unique identifier for this result, 1-64 bytes
* @method string getAudioFileId() A valid file identifier for the audio file
* @method InlineKeyboardMarkup getReplyMarkup() Optional. An Inline keyboard attached to the message
* @method InputMessageContent getInputMessageContent() Optional. Content of the message to be sent instead of the audio
*
* @method $this setId(string $id) Unique identifier for this result, 1-64 bytes
* @method $this setAudioFileId(string $audio_file_id) A valid file identifier for the audio file
* @method $this setReplyMarkup(InlineKeyboardMarkup $reply_markup) Optional. Inline keyboard attached to the message
* @method $this setInputMessageContent(InputMessageContent $input_message_content) Optional. Content of the message to be sent instead of the photo
*/
class InlineQueryResultCachedAudio extends InlineEntity
{
/**
* InlineQueryResultCachedAudio constructor
*
* @param array $data
*
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function __construct(array $data = [])
{
$data['type'] = 'audio';
parent::__construct($data);
}
}
<?php
/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Longman\TelegramBot\Entities\InlineQuery;
use Longman\TelegramBot\Entities\InlineKeyboardMarkup;
use Longman\TelegramBot\Entities\InputMessageContent\InputMessageContent;
/**
* Class InlineQueryResultCachedDocument
*
* @link https://core.telegram.org/bots/api#inlinequeryresultcacheddocument
*
* <code>
* $data = [
* 'id' => '',
* 'title' => '',
* 'document_file_id' => '',
* 'description' => '',
* 'caption' => '',
* 'reply_markup' => <InlineKeyboardMarkup>,
* 'input_message_content' => <InputMessageContent>,
* ];
* </code>
*
* @method string getType() Type of the result, must be document
* @method string getId() Unique identifier for this result, 1-64 bytes
* @method string getTitle() Title for the result
* @method string getDocumentFileId() A valid file identifier for the file
* @method string getDescription() Optional. Short description of the result
* @method string getCaption() Optional. Caption of the document to be sent, 0-200 characters
* @method InlineKeyboardMarkup getReplyMarkup() Optional. An Inline keyboard attached to the message
* @method InputMessageContent getInputMessageContent() Optional. Content of the message to be sent instead of the file
*
* @method $this setId(string $id) Unique identifier for this result, 1-64 bytes
* @method $this setTitle(string $title) Title for the result
* @method $this setDocumentFileId(string $document_file_id) A valid file identifier for the file
* @method $this setDescription(string $description) Optional. Short description of the result
* @method $this setCaption(string $caption) Optional. Caption of the document to be sent, 0-200 characters
* @method $this setReplyMarkup(InlineKeyboardMarkup $reply_markup) Optional. Inline keyboard attached to the message
* @method $this setInputMessageContent(InputMessageContent $input_message_content) Optional. Content of the message to be sent instead of the file
*/
class InlineQueryResultCachedDocument extends InlineEntity
{
/**
* InlineQueryResultCachedDocument constructor
*
* @param array $data
*
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function __construct(array $data = [])
{
$data['type'] = 'document';
parent::__construct($data);
}
}
<?php
/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Longman\TelegramBot\Entities\InlineQuery;
use Longman\TelegramBot\Entities\InlineKeyboardMarkup;
use Longman\TelegramBot\Entities\InputMessageContent\InputMessageContent;
/**
* Class InlineQueryResultCachedGif
*
* @link https://core.telegram.org/bots/api#inlinequeryresultcachedgif
*
* <code>
* $data = [
* 'id' => '',
* 'gif_file_id' => '',
* 'title' => '',
* 'caption' => '',
* 'reply_markup' => <InlineKeyboardMarkup>,
* 'input_message_content' => <InputMessageContent>,
* ];
* </code>
*
* @method string getType() Type of the result, must be gif
* @method string getId() Unique identifier for this result, 1-64 bytes
* @method string getGifFileId() A valid file identifier for the GIF file
* @method string getTitle() Optional. Title for the result
* @method string getCaption() Optional. Caption of the GIF file to be sent, 0-200 characters
* @method InlineKeyboardMarkup getReplyMarkup() Optional. An Inline keyboard attached to the message
* @method InputMessageContent getInputMessageContent() Optional. Content of the message to be sent instead of the GIF animation
*
* @method $this setId(string $id) Unique identifier for this result, 1-64 bytes
* @method $this setGifFileId(string $gif_file_id) A valid file identifier for the GIF file
* @method $this setTitle(string $title) Optional. Title for the result
* @method $this setCaption(string $caption) Optional. Caption of the GIF file to be sent, 0-200 characters
* @method $this setReplyMarkup(InlineKeyboardMarkup $reply_markup) Optional. Inline keyboard attached to the message
* @method $this setInputMessageContent(InputMessageContent $input_message_content) Optional. Content of the message to be sent instead of the photo
*/
class InlineQueryResultCachedGif extends InlineEntity
{
/**
* InlineQueryResultCachedGif constructor
*
* @param array $data
*
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function __construct(array $data = [])
{
$data['type'] = 'gif';
parent::__construct($data);
}
}
<?php
/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Longman\TelegramBot\Entities\InlineQuery;
use Longman\TelegramBot\Entities\InlineKeyboardMarkup;
use Longman\TelegramBot\Entities\InputMessageContent\InputMessageContent;
/**
* Class InlineQueryResultCachedMpeg4Gif
*
* @link https://core.telegram.org/bots/api#inlinequeryresultcachedmpeg4gif
*
* <code>
* $data = [
* 'id' => '',
* 'mpeg4_file_id' => '',
* 'title' => '',
* 'caption' => '',
* 'reply_markup' => <InlineKeyboardMarkup>,
* 'input_message_content' => <InputMessageContent>,
* ];
* </code>
*
* @method String getType() Type of the result, must be mpeg4_gif
* @method String getId() Unique identifier for this result, 1-64 bytes
* @method String getMpeg4FileId() A valid file identifier for the MP4 file
* @method String getTitle() Optional. Title for the result
* @method String getCaption() Optional. Caption of the MPEG-4 file to be sent, 0-200 characters
* @method InlineKeyboardMarkup getReplyMarkup() Optional. An Inline keyboard attached to the message
* @method InputMessageContent getInputMessageContent() Optional. Content of the message to be sent instead of the video animation
*
* @method $this setId(string $id) Unique identifier for this result, 1-64 bytes
* @method $this setMpeg4FileId(string $mpeg4_file_id) A valid file identifier for the MP4 file
* @method $this setTitle(string $title) Optional. Title for the result
* @method $this setCaption(string $caption) Optional. Caption of the MPEG-4 file to be sent, 0-200 characters
* @method $this setReplyMarkup(InlineKeyboardMarkup $reply_markup) Optional. Inline keyboard attached to the message
* @method $this setInputMessageContent(InputMessageContent $input_message_content) Optional. Content of the message to be sent instead of the video animation
*/
class InlineQueryResultCachedMpeg4Gif extends InlineEntity
{
/**
* InlineQueryResultCachedMpeg4Gif constructor
*
* @param array $data
*
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function __construct(array $data = [])
{
$data['type'] = 'mpeg4_gif';
parent::__construct($data);
}
}
......@@ -8,42 +8,20 @@
* file that was distributed with this source code.
*/
namespace Longman\TelegramBot\Entities;
namespace Longman\TelegramBot\Entities\InlineQuery;
use Longman\TelegramBot\Exception\TelegramException;
class InlineQueryResultCachedAudio extends InlineQueryResult
class InlineQueryResultCachedPhoto extends InlineEntity
{
/**
* @var mixed|null
*/
protected $audio_file_id;
/**
* InlineQueryResultCachedAudio constructor.
* InlineQueryResultCachedPhoto constructor
*
* @param array $data
*
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function __construct(array $data)
public function __construct(array $data = [])
{
$data['type'] = 'photo';
parent::__construct($data);
$this->type = 'audio';
$this->audio_file_id = isset($data['audio_file_id']) ? $data['audio_file_id'] : null;
if (empty($this->audio_file_id)) {
throw new TelegramException('audio_file_id is empty!');
}
}
/**
* Get audio file id
*
* @return mixed|null
*/
public function getAudioFileId()
{
return $this->audio_file_id;
}
}
......@@ -8,42 +8,20 @@
* file that was distributed with this source code.
*/
namespace Longman\TelegramBot\Entities;
namespace Longman\TelegramBot\Entities\InlineQuery;
use Longman\TelegramBot\Exception\TelegramException;
class InlineQueryResultCachedSticker extends InlineQueryResult
class InlineQueryResultCachedSticker extends InlineEntity
{
/**
* @var mixed|null
*/
protected $sticker_file_id;
/**
* InlineQueryResultCachedSticker constructor.
* InlineQueryResultCachedSticker constructor
*
* @param array $data
*
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function __construct(array $data)
public function __construct(array $data = [])
{
$data['type'] = 'sticker';
parent::__construct($data);
$this->type = 'sticker';
$this->photo_file_id = isset($data['sticker_file_id']) ? $data['sticker_file_id'] : null;
if (empty($this->sticker_file_id)) {
throw new TelegramException('sticker_file_id is empty!');
}
}
/**
* Get sticker file id
*
* @return mixed|null
*/
public function getStickerFileId()
{
return $this->sticker_file_id;
}
}
......@@ -8,38 +8,20 @@
* file that was distributed with this source code.
*/
namespace Longman\TelegramBot\Entities;
namespace Longman\TelegramBot\Entities\InlineQuery;
use Longman\TelegramBot\Exception\TelegramException;
class InputLocationMessageContent extends InputMessageContent
class InlineQueryResultCachedVideo extends InlineEntity
{
/**
* @var mixed|null
*/
protected $latitude;
/**
* @var mixed|null
*/
protected $longitude;
/**
* InputLocationMessageContent constructor.
* InlineQueryResultCachedVideo constructor
*
* @param array $data
*
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function __construct(array $data)
public function __construct(array $data = [])
{
$this->latitude = isset($data['latitude']) ? $data['latitude'] : null;
if (empty($this->latitude)) {
throw new TelegramException('latitude is empty!');
}
$this->longitude = isset($data['longitude']) ? $data['longitude'] : null;
if (empty($this->longitude)) {
throw new TelegramException('longitude is empty!');
}
$data['type'] = 'video';
parent::__construct($data);
}
}
<?php
/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Longman\TelegramBot\Entities\InlineQuery;
class InlineQueryResultCachedVoice extends InlineEntity
{
/**
* InlineQueryResultCachedVoice constructor
*
* @param array $data
*
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function __construct(array $data = [])
{
$data['type'] = 'voice';
parent::__construct($data);
}
}
<?php
/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Longman\TelegramBot\Entities\InlineQuery;
class InlineQueryResultContact extends InlineEntity
{
/**
* InlineQueryResultContact constructor
*
* @param array $data
*
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function __construct(array $data = [])
{
$data['type'] = 'contact';
parent::__construct($data);
}
}
<?php
/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Longman\TelegramBot\Entities\InlineQuery;
class InlineQueryResultDocument extends InlineEntity
{
/**
* InlineQueryResultDocument constructor
*
* @param array $data
*
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function __construct(array $data = [])
{
$data['type'] = 'document';
parent::__construct($data);
}
}
<?php
/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Longman\TelegramBot\Entities\InlineQuery;
class InlineQueryResultGif extends InlineEntity
{
/**
* InlineQueryResultGif constructor
*
* @param array $data
*
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function __construct(array $data = [])
{
$data['type'] = 'gif';
parent::__construct($data);
}
}
<?php
/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Longman\TelegramBot\Entities\InlineQuery;
class InlineQueryResultLocation extends InlineEntity
{
/**
* InlineQueryResultLocation constructor
*
* @param array $data
*
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function __construct(array $data = [])
{
$data['type'] = 'location';
parent::__construct($data);
}
}
<?php
/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Longman\TelegramBot\Entities\InlineQuery;
class InlineQueryResultMpeg4Gif extends InlineEntity
{
/**
* InlineQueryResultMpeg4Gif constructor
*
* @param array $data
*
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function __construct(array $data = [])
{
$data['type'] = 'mpeg4_gif';
parent::__construct($data);
}
}
<?php
/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Longman\TelegramBot\Entities\InlineQuery;
class InlineQueryResultPhoto extends InlineEntity
{
/**
* InlineQueryResultPhoto constructor
*
* @param array $data
*
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function __construct(array $data = [])
{
$data['type'] = 'photo';
parent::__construct($data);
}
}
<?php
/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Longman\TelegramBot\Entities\InlineQuery;
class InlineQueryResultVenue extends InlineEntity
{
/**
* InlineQueryResultVenue constructor
*
* @param array $data
*
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function __construct(array $data = [])
{
$data['type'] = 'venue';
parent::__construct($data);
}
}
<?php
/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Longman\TelegramBot\Entities\InlineQuery;
class InlineQueryResultVideo extends InlineEntity
{
/**
* InlineQueryResultVideo constructor
*
* @param array $data
*
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function __construct(array $data = [])
{
$data['type'] = 'video';
parent::__construct($data);
}
}
<?php
/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Longman\TelegramBot\Entities\InlineQuery;
class InlineQueryResultVoice extends InlineEntity
{
/**
* InlineQueryResultVoice constructor
*
* @param array $data
*
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function __construct(array $data = [])
{
$data['type'] = 'voice';
parent::__construct($data);
}
}
<?php
/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Longman\TelegramBot\Entities;
use Longman\TelegramBot\Exception\TelegramException;
class InlineQueryResult extends Entity
{
/**
* @var string
*/
protected $type;
/**
* @var mixed|null
*/
protected $id;
/**
* @var mixed|null
*/
protected $input_message_content;
/**
* @var mixed|null
*/
protected $reply_markup;
/**
* InlineQueryResult constructor.
*
* @param array $data
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function __construct(array $data)
{
$this->type = null;
$this->id = isset($data['id']) ? $data['id'] : null;
if (empty($this->id)) {
throw new TelegramException('id is empty!');
}
$this->input_message_content = isset($data['input_message_content']) ? $data['input_message_content'] : null;
$this->reply_markup = isset($data['reply_markup']) ? $data['reply_markup'] : null;
}
/**
* Get type
*
* @return string
*/
public function getType()
{
return $this->type;
}
/**
* Get id
*
* @return mixed|null
*/
public function getId()
{
return $this->id;
}
/**
* Get input message content
*
* @return mixed|null
*/
public function getInputMessageContent()
{
return $this->input_message_content;
}
/**
* Get reply markup
*
* @return mixed|null
*/
public function getReplyMarkup()
{
return $this->reply_markup;
}
}
<?php
/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Longman\TelegramBot\Entities;
use Longman\TelegramBot\Exception\TelegramException;
class InlineQueryResultArticle extends InlineQueryResult
{
/**
* @var mixed|null
*/
protected $title;
/**
* @var mixed|null
*/
protected $input_message_content;
/**
* @var mixed|null
*/
protected $url;
/**
* @var mixed|null
*/
protected $hide_url;
/**
* @var mixed|null
*/
protected $description;
/**
* @var mixed|null
*/
protected $thumb_url;
/**
* @var mixed|null
*/
protected $thumb_width;
/**
* @var mixed|null
*/
protected $thumb_height;
/**
* InlineQueryResultArticle constructor.
*
* @param array $data
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function __construct(array $data)
{
parent::__construct($data);
$this->type = 'article';
$this->title = isset($data['title']) ? $data['title'] : null;
if (empty($this->title)) {
throw new TelegramException('title is empty!');
}
$this->input_message_content = isset($data['input_message_content']) ? $data['input_message_content'] : null;
if (empty($this->input_message_content)) {
throw new TelegramException('input_message_content is empty!');
}
$this->url = isset($data['url']) ? $data['url'] : null;
$this->hide_url = isset($data['hide_url']) ? $data['hide_url'] : null;
$this->description = isset($data['description']) ? $data['description'] : null;
$this->thumb_url = isset($data['thumb_url']) ? $data['thumb_url'] : null;
$this->thumb_width = isset($data['thumb_width']) ? $data['thumb_width'] : null;
$this->thumb_height = isset($data['thumb_height']) ? $data['thumb_height'] : null;
}
/**
* Get title
*
* @return mixed|null
*/
public function getTitle()
{
return $this->title;
}
/**
* Get input message content
*
* @return mixed|null
*/
public function getInputMessageContent()
{
return $this->input_message_content;
}
/**
* Get url
*
* @return mixed|null
*/
public function getUrl()
{
return $this->url;
}
/**
* Get hide url
*
* @return mixed|null
*/
public function getHideUrl()
{
return $this->hide_url;
}
/**
* Get description
*
* @return mixed|null
*/
public function getDescription()
{
return $this->description;
}
/**
* Get thumb url
*
* @return mixed|null
*/
public function getThumbUrl()
{
return $this->thumb_url;
}
/**
* Get thumb width
*
* @return mixed|null
*/
public function getThumbWidth()
{
return $this->thumb_width;
}
/**
* Get thumb height
*
* @return mixed|null
*/
public function getThumbHeight()
{
return $this->thumb_height;
}
}
<?php
/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Longman\TelegramBot\Entities;
use Longman\TelegramBot\Exception\TelegramException;
class InlineQueryResultAudio extends InlineQueryResult
{
/**
* @var mixed|null
*/
protected $audio_url;
/**
* @var mixed|null
*/
protected $title;
/**
* @var mixed|null
*/
protected $performer;
/**
* @var mixed|null
*/
protected $audio_duration;
/**
* InlineQueryResultAudio constructor.
*
* @param array $data
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function __construct(array $data)
{
parent::__construct($data);
$this->type = 'audio';
$this->audio_url = isset($data['audio_url']) ? $data['audio_url'] : null;
if (empty($this->audio_url)) {
throw new TelegramException('audio_url is empty!');
}
$this->title = isset($data['title']) ? $data['title'] : null;
if (empty($this->title)) {
throw new TelegramException('title is empty!');
}
$this->performer = isset($data['performer']) ? $data['performer'] : null;
$this->audio_duration = isset($data['audio_duration']) ? $data['audio_duration'] : null;
}
/**
* Get audio url
*
* @return mixed|null
*/
public function getAudioUrl()
{
return $this->audio_url;
}
/**
* Get title
*
* @return mixed|null
*/
public function getTitle()
{
return $this->title;
}
/**
* Get performer
*
* @return mixed|null
*/
public function getPerformer()
{
return $this->performer;
}
/**
* Get audio duration
*
* @return mixed|null
*/
public function getAudioDuration()
{
return $this->audio_duration;
}
}
<?php
/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Longman\TelegramBot\Entities;
use Longman\TelegramBot\Exception\TelegramException;
class InlineQueryResultCachedDocument extends InlineQueryResult
{
/**
* @var mixed|null
*/
protected $document_file_id;
/**
* @var mixed|null
*/
protected $title;
/**
* @var mixed|null
*/
protected $description;
/**
* @var mixed|null
*/
protected $caption;
/**
* InlineQueryResultCachedDocument constructor.
*
* @param array $data
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function __construct(array $data)
{
parent::__construct($data);
$this->type = 'document';
$this->document_file_id = isset($data['document_file_id']) ? $data['document_file_id'] : null;
if (empty($this->document_file_id)) {
throw new TelegramException('document_file_id is empty!');
}
$this->title = isset($data['title']) ? $data['title'] : null;
if (empty($this->title)) {
throw new TelegramException('title is empty!');
}
$this->description = isset($data['description']) ? $data['description'] : null;
$this->caption = isset($data['caption']) ? $data['caption'] : null;
}
/**
* Get document file id
*
* @return mixed|null
*/
public function getDocumentFileId()
{
return $this->document_file_id;
}
/**
* Get title
*
* @return mixed|null
*/
public function getTitle()
{
return $this->title;
}
/**
* Get description
*
* @return mixed|null
*/
public function getDescription()
{
return $this->description;
}
/**
* Get caption
*
* @return mixed|null
*/
public function getCaption()
{
return $this->caption;
}
}
<?php
/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Longman\TelegramBot\Entities;
use Longman\TelegramBot\Exception\TelegramException;
class InlineQueryResultCachedGif extends InlineQueryResult
{
/**
* @var mixed|null
*/
protected $gif_file_id;
/**
* @var mixed|null
*/
protected $title;
/**
* @var
*/
protected $description;
/**
* @var mixed|null
*/
protected $caption;
/**
* InlineQueryResultCachedGif constructor.
*
* @param array $data
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function __construct(array $data)
{
parent::__construct($data);
$this->type = 'gif';
$this->gif_file_id = isset($data['gif_file_id']) ? $data['gif_file_id'] : null;
if (empty($this->gif_file_id)) {
throw new TelegramException('gif_file_id is empty!');
}
$this->title = isset($data['title']) ? $data['title'] : null;
$this->caption = isset($data['caption']) ? $data['caption'] : null;
}
/**
* Get gif file id
*
* @return mixed|null
*/
public function getGifFileId()
{
return $this->gif_file_id;
}
/**
* Get title
*
* @return mixed|null
*/
public function getTitle()
{
return $this->title;
}
/**
* Get caption
*
* @return mixed|null
*/
public function getCaption()
{
return $this->caption;
}
}
<?php
/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Longman\TelegramBot\Entities;
use Longman\TelegramBot\Exception\TelegramException;
class InlineQueryResultCachedMpeg4Gif extends InlineQueryResult
{
/**
* @var mixed|null
*/
protected $mpeg4_file_id;
/**
* @var mixed|null
*/
protected $title;
/**
* @var mixed|null
*/
protected $caption;
/**
* InlineQueryResultCachedMpeg4Gif constructor.
*
* @param array $data
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function __construct(array $data)
{
parent::__construct($data);
$this->type = 'mpeg4_gif';
$this->mpeg4_file_id = isset($data['mpeg4_file_id']) ? $data['mpeg4_file_id'] : null;
if (empty($this->mpeg4_file_id)) {
throw new TelegramException('mpeg4_file_id is empty!');
}
$this->title = isset($data['title']) ? $data['title'] : null;
$this->caption = isset($data['caption']) ? $data['caption'] : null;
}
/**
* Get mp4 file id
*
* @return mixed|null
*/
public function getMpeg4FileId()
{
return $this->mpeg4_file_id;
}
/**
* Get title
*
* @return mixed|null
*/
public function getTitle()
{
return $this->title;
}
/**
* Get caption
*
* @return mixed|null
*/
public function getCaption()
{
return $this->caption;
}
}
<?php
/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Longman\TelegramBot\Entities;
use Longman\TelegramBot\Exception\TelegramException;
class InlineQueryResultCachedPhoto extends InlineQueryResult
{
/**
* @var mixed|null
*/
protected $photo_file_id;
/**
* @var mixed|null
*/
protected $title;
/**
* @var mixed|null
*/
protected $description;
/**
* @var mixed|null
*/
protected $caption;
/**
* InlineQueryResultCachedPhoto constructor.
*
* @param array $data
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function __construct(array $data)
{
parent::__construct($data);
$this->type = 'photo';
$this->photo_file_id = isset($data['photo_file_id']) ? $data['photo_file_id'] : null;
if (empty($this->photo_file_id)) {
throw new TelegramException('photo_file_id is empty!');
}
$this->title = isset($data['title']) ? $data['title'] : null;
$this->description = isset($data['description']) ? $data['description'] : null;
$this->caption = isset($data['caption']) ? $data['caption'] : null;
}
/**
* Get photo file id
*
* @return mixed|null
*/
public function getPhotoFileId()
{
return $this->photo_file_id;
}
/**
* Get title
*
* @return mixed|null
*/
public function getTitle()
{
return $this->title;
}
/**
* Get description
*
* @return mixed|null
*/
public function getDescription()
{
return $this->description;
}
/**
* Get caption
*
* @return mixed|null
*/
public function getCaption()
{
return $this->caption;
}
}
<?php
/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Longman\TelegramBot\Entities;
use Longman\TelegramBot\Exception\TelegramException;
class InlineQueryResultCachedVideo extends InlineQueryResult
{
/**
* @var mixed|null
*/
protected $video_file_id;
/**
* @var mixed|null
*/
protected $title;
/**
* @var mixed|null
*/
protected $description;
/**
* @var mixed|null
*/
protected $caption;
/**
* InlineQueryResultCachedVideo constructor.
*
* @param array $data
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function __construct(array $data)
{
parent::__construct($data);
$this->type = 'photo';
$this->video_file_id = isset($data['video_file_id']) ? $data['video_file_id'] : null;
if (empty($this->video_file_id)) {
throw new TelegramException('video_file_id is empty!');
}
$this->title = isset($data['title']) ? $data['title'] : null;
if (empty($this->title)) {
throw new TelegramException('title is empty!');
}
$this->description = isset($data['description']) ? $data['description'] : null;
$this->caption = isset($data['caption']) ? $data['caption'] : null;
}
/**
* Get video file id
*
* @return mixed|null
*/
public function getVideoFileId()
{
return $this->video_file_id;
}
/**
* Get title
*
* @return mixed|null
*/
public function getTitle()
{
return $this->title;
}
/**
* Get description
*
* @return mixed|null
*/
public function getDescription()
{
return $this->description;
}
/**
* Get caption
*
* @return mixed|null
*/
public function getCaption()
{
return $this->caption;
}
}
<?php
/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Longman\TelegramBot\Entities;
use Longman\TelegramBot\Exception\TelegramException;
class InlineQueryResultCachedVoice extends InlineQueryResult
{
/**
* @var mixed|null
*/
protected $voice_file_id;
/**
* @var mixed|null
*/
protected $title;
/**
* @var mixed|null
*/
protected $description;
/**
* @var mixed|null
*/
protected $caption;
/**
* InlineQueryResultCachedVoice constructor.
*
* @param array $data
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function __construct(array $data)
{
parent::__construct($data);
$this->type = 'voice';
$this->voice_file_id = isset($data['voice_file_id']) ? $data['voice_file_id'] : null;
if (empty($this->voice_file_id)) {
throw new TelegramException('voice_file_id is empty!');
}
$this->title = isset($data['title']) ? $data['title'] : null;
if (empty($this->title)) {
throw new TelegramException('title is empty!');
}
$this->description = isset($data['description']) ? $data['description'] : null;
$this->caption = isset($data['caption']) ? $data['caption'] : null;
}
/**
* Get voice file id
*
* @return mixed|null
*/
public function getVoiceFileId()
{
return $this->voice_file_id;
}
/**
* Get title
*
* @return mixed|null
*/
public function getTitle()
{
return $this->title;
}
/**
* Get description
*
* @return mixed|null
*/
public function getDescription()
{
return $this->description;
}
/**
* Get caption
*
* @return mixed|null
*/
public function getCaption()
{
return $this->caption;
}
}
<?php
/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Longman\TelegramBot\Entities;
use Longman\TelegramBot\Exception\TelegramException;
class InlineQueryResultContact extends InlineQueryResult
{
/**
* @var mixed|null
*/
protected $phone_number;
/**
* @var mixed|null
*/
protected $first_name;
/**
* @var mixed|null
*/
protected $last_name;
/**
* @var mixed|null
*/
protected $thumb_url;
/**
* @var mixed|null
*/
protected $thumb_width;
/**
* @var mixed|null
*/
protected $thumb_height;
/**
* InlineQueryResultContact constructor.
*
* @param array $data
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function __construct(array $data)
{
parent::__construct($data);
$this->type = 'contact';
$this->phone_number = isset($data['phone_number']) ? $data['phone_number'] : null;
if (empty($this->phone_number)) {
throw new TelegramException('phone_number is empty!');
}
$this->first_name = isset($data['first_name']) ? $data['first_name'] : null;
if (empty($this->first_name)) {
throw new TelegramException('first_name is empty!');
}
$this->last_name = isset($data['last_name']) ? $data['last_name'] : null;
$this->thumb_url = isset($data['thumb_url']) ? $data['thumb_url'] : null;
$this->thumb_width = isset($data['thumb_width']) ? $data['thumb_width'] : null;
$this->thumb_height = isset($data['thumb_height']) ? $data['thumb_height'] : null;
}
/**
* Get phone number
*
* @return mixed|null
*/
public function getPhoneNumber()
{
return $this->phone_number;
}
/**
* Get first name
*
* @return mixed|null
*/
public function getFirstName()
{
return $this->first_name;
}
/**
* Get last name
*
* @return mixed|null
*/
public function getLastName()
{
return $this->last_name;
}
/**
* Get thumb url
*
* @return mixed|null
*/
public function getThumbUrl()
{
return $this->thumb_url;
}
/**
* Get thumb width
*
* @return mixed|null
*/
public function getThumbWidth()
{
return $this->thumb_width;
}
/**
* Get thumb height
*
* @return mixed|null
*/
public function getThumbHeight()
{
return $this->thumb_height;
}
}
<?php
/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Longman\TelegramBot\Entities;
use Longman\TelegramBot\Exception\TelegramException;
class InlineQueryResultDocument extends InlineQueryResult
{
/**
* @var mixed|null
*/
protected $title;
/**
* @var mixed|null
*/
protected $caption;
/**
* @var mixed|null
*/
protected $document_url;
/**
* @var mixed|null
*/
protected $mime_type;
/**
* @var mixed|null
*/
protected $description;
/**
* @var mixed|null
*/
protected $thumb_url;
/**
* @var mixed|null
*/
protected $thumb_width;
/**
* @var mixed|null
*/
protected $thumb_height;
/**
* InlineQueryResultDocument constructor.
*
* @param array $data
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function __construct(array $data)
{
parent::__construct($data);
$this->type = 'document';
$this->title = isset($data['title']) ? $data['title'] : null;
if (empty($this->title)) {
throw new TelegramException('title is empty!');
}
$this->caption = isset($data['caption']) ? $data['caption'] : null;
$this->document_url = isset($data['document_url']) ? $data['document_url'] : null;
if (empty($this->document_url)) {
throw new TelegramException('document_url is empty!');
}
$this->mime_type = isset($data['mime_type']) ? $data['mime_type'] : null;
if (empty($this->mime_type)) {
throw new TelegramException('mime_type is empty!');
}
$this->description = isset($data['description']) ? $data['description'] : null;
$this->thumb_url = isset($data['thumb_url']) ? $data['thumb_url'] : null;
$this->thumb_width = isset($data['thumb_width']) ? $data['thumb_width'] : null;
$this->thumb_height = isset($data['thumb_height']) ? $data['thumb_height'] : null;
}
/**
* Get title
*
* @return mixed|null
*/
public function getTitle()
{
return $this->title;
}
/**
* Get caption
*
* @return mixed|null
*/
public function getCaption()
{
return $this->caption;
}
/**
* Get document url
*
* @return mixed|null
*/
public function getDocumentUrl()
{
return $this->document_url;
}
/**
* Get mime type
*
* @return mixed|null
*/
public function getMimeType()
{
return $this->mime_type;
}
/**
* Get description
*
* @return mixed|null
*/
public function getDescription()
{
return $this->description;
}
/**
* Get thumb url
*
* @return mixed|null
*/
public function getThumbUrl()
{
return $this->thumb_url;
}
/**
* Get thumb width
*
* @return mixed|null
*/
public function getThumbWidth()
{
return $this->thumb_width;
}
/**
* Get thumb height
*
* @return mixed|null
*/
public function getThumbHeight()
{
return $this->thumb_height;
}
}
<?php
/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Longman\TelegramBot\Entities;
use Longman\TelegramBot\Exception\TelegramException;
class InlineQueryResultGif extends InlineQueryResult
{
/**
* @var mixed|null
*/
protected $gif_url;
/**
* @var mixed|null
*/
protected $gif_width;
/**
* @var mixed|null
*/
protected $gif_height;
/**
* @var mixed|null
*/
protected $thumb_url;
/**
* @var mixed|null
*/
protected $title;
/**
* @var mixed|null
*/
protected $caption;
/**
* InlineQueryResultGif constructor.
*
* @param array $data
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function __construct(array $data)
{
parent::__construct($data);
$this->type = 'gif';
$this->gif_url = isset($data['gif_url']) ? $data['gif_url'] : null;
if (empty($this->gif_url)) {
throw new TelegramException('gif_url is empty!');
}
$this->gif_width = isset($data['gif_width']) ? $data['gif_width'] : null;
$this->gif_height = isset($data['gif_height']) ? $data['gif_height'] : null;
$this->thumb_url = isset($data['thumb_url']) ? $data['thumb_url'] : null;
if (empty($this->thumb_url)) {
throw new TelegramException('thumb_url is empty!');
}
$this->title = isset($data['title']) ? $data['title'] : null;
$this->caption = isset($data['caption']) ? $data['caption'] : null;
}
/**
* Get gif url
*
* @return mixed|null
*/
public function getGifUrl()
{
return $this->gif_url;
}
/**
* Get gif width
*
* @return mixed|null
*/
public function getGifWidth()
{
return $this->gif_width;
}
/**
* Get gif height
*
* @return mixed|null
*/
public function getGifHeight()
{
return $this->gif_height;
}
/**
* Get thumb url
*
* @return mixed|null
*/
public function getThumbUrl()
{
return $this->thumb_url;
}
/**
* Get title
*
* @return mixed|null
*/
public function getTitle()
{
return $this->title;
}
/**
* Get caption
*
* @return mixed|null
*/
public function getCaption()
{
return $this->caption;
}
}
<?php
/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Longman\TelegramBot\Entities;
use Longman\TelegramBot\Exception\TelegramException;
class InlineQueryResultLocation extends InlineQueryResult
{
/**
* @var mixed|null
*/
protected $latitude;
/**
* @var mixed|null
*/
protected $longitude;
/**
* @var mixed|null
*/
protected $title;
/**
* @var mixed|null
*/
protected $thumb_url;
/**
* @var mixed|null
*/
protected $thumb_width;
/**
* @var mixed|null
*/
protected $thumb_height;
/**
* InlineQueryResultLocation constructor.
*
* @param array $data
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function __construct(array $data)
{
parent::__construct($data);
$this->type = 'location';
$this->latitude = isset($data['latitude']) ? $data['latitude'] : null;
if (empty($this->latitude)) {
throw new TelegramException('latitude is empty!');
}
$this->longitude = isset($data['longitude']) ? $data['longitude'] : null;
if (empty($this->longitude)) {
throw new TelegramException('longitude is empty!');
}
$this->title = isset($data['title']) ? $data['title'] : null;
if (empty($this->title)) {
throw new TelegramException('title is empty!');
}
$this->thumb_url = isset($data['thumb_url']) ? $data['thumb_url'] : null;
$this->thumb_width = isset($data['thumb_width']) ? $data['thumb_width'] : null;
$this->thumb_height = isset($data['thumb_height']) ? $data['thumb_height'] : null;
}
/**
* Get latitude
*
* @return mixed|null
*/
public function getLatitude()
{
return $this->latitude;
}
/**
* Get longitude
*
* @return mixed|null
*/
public function getLongitude()
{
return $this->longitude;
}
/**
* Get title
*
* @return mixed|null
*/
public function getTitle()
{
return $this->title;
}
/**
* Get thumb url
*
* @return mixed|null
*/
public function getThumbUrl()
{
return $this->thumb_url;
}
/**
* Get thumb width
*
* @return mixed|null
*/
public function getThumbWidth()
{
return $this->thumb_width;
}
/**
* Get thumb height
*
* @return mixed|null
*/
public function getThumbHeight()
{
return $this->thumb_height;
}
}
<?php
/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Longman\TelegramBot\Entities;
use Longman\TelegramBot\Exception\TelegramException;
class InlineQueryResultMpeg4Gif extends InlineQueryResult
{
/**
* @var mixed|null
*/
protected $mpeg4_url;
/**
* @var mixed|null
*/
protected $mpeg4_width;
/**
* @var mixed|null
*/
protected $mpeg4_height;
/**
* @var mixed|null
*/
protected $thumb_url;
/**
* @var mixed|null
*/
protected $title;
/**
* @var mixed|null
*/
protected $caption;
/**
* InlineQueryResultMpeg4Gif constructor.
*
* @param array $data
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function __construct(array $data)
{
parent::__construct($data);
$this->type = 'mpeg4_gif';
$this->mpeg4_url = isset($data['mpeg4_url']) ? $data['mpeg4_url'] : null;
if (empty($this->mpeg4_url)) {
throw new TelegramException('mpeg4_url is empty!');
}
$this->mpeg4_width = isset($data['mpeg4_width']) ? $data['mpeg4_width'] : null;
$this->mpeg4_height = isset($data['mpeg4_height']) ? $data['mpeg4_height'] : null;
$this->thumb_url = isset($data['thumb_url']) ? $data['thumb_url'] : null;
if (empty($this->thumb_url)) {
throw new TelegramException('thumb_url is empty!');
}
$this->title = isset($data['title']) ? $data['title'] : null;
$this->caption = isset($data['caption']) ? $data['caption'] : null;
}
/**
* Get mp4 url
*
* @return mixed|null
*/
public function getMpeg4Url()
{
return $this->mpeg4_url;
}
/**
* Get mp4 width
*
* @return mixed|null
*/
public function getMpeg4Width()
{
return $this->mpeg4_width;
}
/**
* Get mp4 height
*
* @return mixed|null
*/
public function getMpeg4Height()
{
return $this->mpeg4_height;
}
/**
* Get thumb url
*
* @return mixed|null
*/
public function getThumbUrl()
{
return $this->thumb_url;
}
/**
* Get title
*
* @return mixed|null
*/
public function getTitle()
{
return $this->title;
}
/**
* Get caption
*
* @return mixed|null
*/
public function getCaption()
{
return $this->caption;
}
}
<?php
/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Longman\TelegramBot\Entities;
use Longman\TelegramBot\Exception\TelegramException;
class InlineQueryResultPhoto extends InlineQueryResult
{
/**
* @var mixed|null
*/
protected $photo_url;
/**
* @var mixed|null
*/
protected $photo_width;
/**
* @var mixed|null
*/
protected $photo_height;
/**
* @var mixed|null
*/
protected $thumb_url;
/**
* @var mixed|null
*/
protected $title;
/**
* @var mixed|null
*/
protected $description;
/**
* @var mixed|null
*/
protected $caption;
/**
* InlineQueryResultPhoto constructor.
*
* @param array $data
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function __construct(array $data)
{
parent::__construct($data);
$this->type = 'photo';
$this->photo_url = isset($data['photo_url']) ? $data['photo_url'] : null;
if (empty($this->photo_url)) {
throw new TelegramException('photo_url is empty!');
}
$this->photo_width = isset($data['photo_width']) ? $data['photo_width'] : null;
$this->photo_height = isset($data['photo_height']) ? $data['photo_height'] : null;
$this->thumb_url = isset($data['thumb_url']) ? $data['thumb_url'] : null;
if (empty($this->thumb_url)) {
throw new TelegramException('thumb_url is empty!');
}
$this->title = isset($data['title']) ? $data['title'] : null;
$this->description = isset($data['description']) ? $data['description'] : null;
$this->caption = isset($data['caption']) ? $data['caption'] : null;
}
/**
* Get photo url
*
* @return mixed|null
*/
public function getPhotoUrl()
{
return $this->photo_url;
}
/**
* Get photo width
*
* @return mixed|null
*/
public function getPhotoWidth()
{
return $this->photo_width;
}
/**
* Get photo height
*
* @return mixed|null
*/
public function getPhotoHeight()
{
return $this->photo_height;
}
/**
* Get thumb url
*
* @return mixed|null
*/
public function getThumbUrl()
{
return $this->thumb_url;
}
/**
* Get title
*
* @return mixed|null
*/
public function getTitle()
{
return $this->title;
}
/**
* Get description
*
* @return mixed|null
*/
public function getDescription()
{
return $this->description;
}
/**
* Get caption
*
* @return mixed|null
*/
public function getCaption()
{
return $this->caption;
}
}
<?php
/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Longman\TelegramBot\Entities;
use Longman\TelegramBot\Exception\TelegramException;
class InlineQueryResultVenue extends InlineQueryResult
{
/**
* @var mixed|null
*/
protected $latitude;
/**
* @var mixed|null
*/
protected $longitude;
/**
* @var mixed|null
*/
protected $title;
/**
* @var mixed|null
*/
protected $address;
/**
* @var mixed|null
*/
protected $foursquare_id;
/**
* @var mixed|null
*/
protected $thumb_url;
/**
* @var mixed|null
*/
protected $thumb_width;
/**
* @var mixed|null
*/
protected $thumb_height;
/**
* InlineQueryResultVenue constructor.
*
* @param array $data
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function __construct(array $data)
{
parent::__construct($data);
$this->type = 'venue';
$this->latitude = isset($data['latitude']) ? $data['latitude'] : null;
if (empty($this->latitude)) {
throw new TelegramException('latitude is empty!');
}
$this->longitude = isset($data['longitude']) ? $data['longitude'] : null;
if (empty($this->longitude)) {
throw new TelegramException('longitude is empty!');
}
$this->title = isset($data['title']) ? $data['title'] : null;
if (empty($this->title)) {
throw new TelegramException('title is empty!');
}
$this->address = isset($data['address']) ? $data['address'] : null;
if (empty($this->address)) {
throw new TelegramException('address is empty!');
}
$this->foursquare_id = isset($data['foursquare_id']) ? $data['foursquare_id'] : null;
$this->thumb_url = isset($data['thumb_url']) ? $data['thumb_url'] : null;
$this->thumb_width = isset($data['thumb_width']) ? $data['thumb_width'] : null;
$this->thumb_height = isset($data['thumb_height']) ? $data['thumb_height'] : null;
}
/**
* Get latitude
*
* @return mixed|null
*/
public function getLatitude()
{
return $this->latitude;
}
/**
* Get longitude
*
* @return mixed|null
*/
public function getLongitude()
{
return $this->longitude;
}
/**
* Get title
*
* @return mixed|null
*/
public function getTitle()
{
return $this->title;
}
/**
* Get address
*
* @return mixed|null
*/
public function getAddress()
{
return $this->address;
}
/**
* Get forsquare id
*
* @return mixed|null
*/
public function getFoursquareId()
{
return $this->foursquare_id;
}
/**
* Get thumb url
*
* @return mixed|null
*/
public function getThumbUrl()
{
return $this->thumb_url;
}
/**
* Get thumb width
*
* @return mixed|null
*/
public function getThumbWidth()
{
return $this->thumb_width;
}
/**
* Get thumb height
*
* @return mixed|null
*/
public function getThumbHeight()
{
return $this->thumb_height;
}
}
<?php
/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Longman\TelegramBot\Entities;
use Longman\TelegramBot\Exception\TelegramException;
class InlineQueryResultVideo extends InlineQueryResult
{
/**
* @var mixed|null
*/
protected $video_url;
/**
* @var mixed|null
*/
protected $mime_type;
/**
* @var mixed|null
*/
protected $thumb_url;
/**
* @var mixed|null
*/
protected $title;
/**
* @var mixed|null
*/
protected $caption;
/**
* @var mixed|null
*/
protected $video_width;
/**
* @var mixed|null
*/
protected $video_height;
/**
* @var mixed|null
*/
protected $video_duration;
/**
* @var mixed|null
*/
protected $description;
/**
* InlineQueryResultVideo constructor.
*
* @param array $data
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function __construct(array $data)
{
parent::__construct($data);
$this->type = 'video';
$this->video_url = isset($data['video_url']) ? $data['video_url'] : null;
if (empty($this->video_url)) {
throw new TelegramException('video_url is empty!');
}
$this->mime_type = isset($data['mime_type']) ? $data['mime_type'] : null;
if (empty($this->mime_type)) {
throw new TelegramException('mime_type is empty!');
}
$this->thumb_url = isset($data['thumb_url']) ? $data['thumb_url'] : null;
if (empty($this->thumb_url)) {
throw new TelegramException('thumb_url is empty!');
}
$this->title = isset($data['title']) ? $data['title'] : null;
$this->caption = isset($data['caption']) ? $data['caption'] : null;
$this->video_width = isset($data['video_width']) ? $data['video_width'] : null;
$this->video_height = isset($data['video_height']) ? $data['video_height'] : null;
$this->video_duration = isset($data['video_duration']) ? $data['video_duration'] : null;
$this->description = isset($data['description']) ? $data['description'] : null;
}
/**
* Get video url
*
* @return mixed|null
*/
public function getVideoUrl()
{
return $this->video_url;
}
/**
* Get mime type
*
* @return mixed|null
*/
public function getMimeType()
{
return $this->mime_type;
}
/**
* Get thumb url
*
* @return mixed|null
*/
public function getThumbUrl()
{
return $this->thumb_url;
}
/**
* Get title
*
* @return mixed|null
*/
public function getTitle()
{
return $this->title;
}
/**
* Get caption
*
* @return mixed|null
*/
public function getCaption()
{
return $this->caption;
}
/**
* Get video width
*
* @return mixed|null
*/
public function getVideoWidth()
{
return $this->video_width;
}
/**
* Get video height
*
* @return mixed|null
*/
public function getVideoHeight()
{
return $this->video_height;
}
/**
* Get video duration
*
* @return mixed|null
*/
public function getVideoDuration()
{
return $this->video_duration;
}
/**
* Get description
*
* @return mixed|null
*/
public function getDescription()
{
return $this->description;
}
}
<?php
/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Longman\TelegramBot\Entities;
use Longman\TelegramBot\Exception\TelegramException;
class InlineQueryResultVoice extends InlineQueryResult
{
/**
* @var mixed|null
*/
protected $voice_url;
/**
* @var mixed|null
*/
protected $title;
/**
* @var mixed|null
*/
protected $voice_duration;
/**
* InlineQueryResultVoice constructor.
*
* @param array $data
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function __construct(array $data)
{
parent::__construct($data);
$this->type = 'voice';
$this->voice_url = isset($data['voice_url']) ? $data['voice_url'] : null;
if (empty($this->voice_url)) {
throw new TelegramException('voice_url is empty!');
}
$this->title = isset($data['title']) ? $data['title'] : null;
if (empty($this->title)) {
throw new TelegramException('title is empty!');
}
$this->voice_duration = isset($data['voice_duration']) ? $data['voice_duration'] : null;
}
/**
* Get voice url
*
* @return mixed|null
*/
public function getVoiceUrl()
{
return $this->voice_url;
}
/**
* Get title
*
* @return mixed|null
*/
public function getTitle()
{
return $this->title;
}
/**
* Get voice duration
*
* @return mixed|null
*/
public function getVoiceDuration()
{
return $this->voice_duration;
}
}
<?php
/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Longman\TelegramBot\Entities;
use Longman\TelegramBot\Exception\TelegramException;
class InputContactMessageContent extends InputMessageContent
{
/**
* @var mixed|null
*/
protected $phone_number;
/**
* @var mixed|null
*/
protected $first_name;
/**
* @var mixed|null
*/
protected $last_name;
/**
* InputContactMessageContent constructor.
*
* @param array $data
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function __construct(array $data)
{
$this->phone_number = isset($data['phone_number']) ? $data['phone_number'] : null;
if (empty($this->phone_number)) {
throw new TelegramException('phone_number is empty!');
}
$this->first_name = isset($data['first_name']) ? $data['first_name'] : null;
if (empty($this->first_name)) {
throw new TelegramException('first_name is empty!');
}
$this->last_name = isset($data['last_name']) ? $data['last_name'] : null;
}
}
<?php
/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Longman\TelegramBot\Entities\InputMessageContent;
use Longman\TelegramBot\Entities\InlineQuery\InlineEntity;
/**
* Class InputContactMessageContent
*
* @link https://core.telegram.org/bots/api#inputcontactmessagecontent
*
* <code>
* $data = [
* 'phone_number' => '',
* 'first_name' => '',
* 'last_name' => '',
* ];
* </code>
*
* @method string getPhoneNumber() Contact's phone number
* @method string getFirstName() Contact's first name
* @method string getLastName() Optional. Contact's last name
*
* @method $this setPhoneNumber(string $phone_number) Contact's phone number
* @method $this setFirstName(string $first_name) Contact's first name
* @method $this setLastName(string $last_name) Optional. Contact's last name
*/
class InputContactMessageContent extends InlineEntity implements InputMessageContent
{
}
<?php
/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Longman\TelegramBot\Entities\InputMessageContent;
use Longman\TelegramBot\Entities\InlineQuery\InlineEntity;
/**
* Class InputLocationMessageContent
*
* @link https://core.telegram.org/bots/api#inputlocationmessagecontent
*
* <code>
* $data = [
* 'latitude' => 36.0338,
* 'longitude' => 71.8601,
* ];
*
* @method float getLatitude() Latitude of the location in degrees
* @method float getLongitude() Longitude of the location in degrees
*
* @method $this setLatitude(float $latitude) Latitude of the location in degrees
* @method $this setLongitude(float $longitude) Longitude of the location in degrees
*/
class InputLocationMessageContent extends InlineEntity implements InputMessageContent
{
}
<?php
namespace Longman\TelegramBot\Entities\InputMessageContent;
interface InputMessageContent
{
}
<?php
/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Longman\TelegramBot\Entities\InputMessageContent;
use Longman\TelegramBot\Entities\InlineQuery\InlineEntity;
/**
* Class InputTextMessageContent
*
* @link https://core.telegram.org/bots/api#inputtextmessagecontent
*
* <code>
* $data = [
* 'message_text' => '',
* 'parse_mode' => '',
* 'disable_web_page_preview' => true,
* ];
* </code>
*
* @method string getMessageText() Text of the message to be sent, 1-4096 characters.
* @method string getParseMode() Optional. Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message.
* @method bool getDisableWebPagePreview() Optional. Disables link previews for links in the sent message
*
* @method $this setMessageText(string $message_text) Text of the message to be sent, 1-4096 characters.
* @method $this setParseMode(string $parse_mode) Optional. Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message.
* @method $this setDisableWebPagePreview(bool $disable_web_page_preview) Optional. Disables link previews for links in the sent message
*/
class InputTextMessageContent extends InlineEntity implements InputMessageContent
{
}
<?php
/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Longman\TelegramBot\Entities\InputMessageContent;
use Longman\TelegramBot\Entities\InlineQuery\InlineEntity;
/**
* Class InputVenueMessageContent
*
* @link https://core.telegram.org/bots/api#inputvenuemessagecontent
*
* <code>
* $data = [
* 'latitude' => 36.0338,
* 'longitude' => 71.8601,
* 'title' => '',
* 'address' => '',
* 'foursquare_id' => '',
* ];
* </code>
*
* @method float getLatitude() Latitude of the location in degrees
* @method float getLongitude() Longitude of the location in degrees
* @method string getTitle() Name of the venue
* @method string getAddress() Address of the venue
* @method string getFoursquareIdTitle() Optional. Foursquare identifier of the venue, if known
*
* @method $this setLatitude(float $latitude) Latitude of the location in degrees
* @method $this setLongitude(float $longitude) Longitude of the location in degrees
* @method $this setTitle(string $title) Name of the venue
* @method $this setAddress(string $address) Address of the venue
* @method $this setFoursquareIdTitle(string $foursquare_id_title) Optional. Foursquare identifier of the venue, if known
*/
class InputVenueMessageContent extends InlineEntity implements InputMessageContent
{
}
<?php
/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Longman\TelegramBot\Entities;
use Longman\TelegramBot\Exception\TelegramException;
class InputTextMessageContent extends InputMessageContent
{
/**
* @var mixed|null
*/
protected $message_text;
/**
* @var mixed|null
*/
protected $parse_mode;
/**
* @var mixed|null
*/
protected $disable_web_page_preview;
/**
* InputTextMessageContent constructor.
*
* @param array $data
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function __construct(array $data)
{
$this->message_text = isset($data['message_text']) ? $data['message_text'] : null;
if (empty($this->message_text)) {
throw new TelegramException('message_text is empty!');
}
$this->parse_mode = isset($data['parse_mode']) ? $data['parse_mode'] : null;
$this->disable_web_page_preview = isset($data['disable_web_page_preview']) ? $data['disable_web_page_preview'] : null;
}
}
<?php
/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Longman\TelegramBot\Entities;
use Longman\TelegramBot\Exception\TelegramException;
class InputVenueMessageContent extends InputMessageContent
{
/**
* @var mixed|null
*/
protected $latitude;
/**
* @var mixed|null
*/
protected $longitude;
/**
* @var mixed|null
*/
protected $title;
/**
* @var mixed|null
*/
protected $address;
/**
* @var mixed|null
*/
protected $foursquare_id;
/**
* InputVenueMessageContent constructor.
*
* @param array $data
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function __construct(array $data)
{
$this->latitude = isset($data['latitude']) ? $data['latitude'] : null;
if (empty($this->latitude)) {
throw new TelegramException('latitude is empty!');
}
$this->longitude = isset($data['longitude']) ? $data['longitude'] : null;
if (empty($this->longitude)) {
throw new TelegramException('longitude is empty!');
}
$this->title = isset($data['title']) ? $data['title'] : null;
if (empty($this->title)) {
throw new TelegramException('title is empty!');
}
$this->address = isset($data['address']) ? $data['address'] : null;
if (empty($this->address)) {
throw new TelegramException('address is empty!');
}
$this->foursquare_id = isset($data['foursquare_id']) ? $data['foursquare_id'] : null;
}
}
......@@ -10,56 +10,15 @@
namespace Longman\TelegramBot\Entities;
use Longman\TelegramBot\Exception\TelegramException;
/**
* Class Location
*
* @link https://core.telegram.org/bots/api#location
*
* @method float getLongitude() Longitude as defined by sender
* @method float getLatitude() Latitude as defined by sender
*/
class Location extends Entity
{
/**
* @var mixed|null
*/
protected $longitude;
/**
* @var mixed|null
*/
protected $latitude;
/**
* Location constructor.
*
* @param array $data
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function __construct(array $data)
{
$this->longitude = isset($data['longitude']) ? $data['longitude'] : null;
if (empty($this->longitude)) {
throw new TelegramException('longitude is empty!');
}
$this->latitude = isset($data['latitude']) ? $data['latitude'] : null;
if (empty($this->latitude)) {
throw new TelegramException('latitude is empty!');
}
}
/**
* Get longitude
*
* @return mixed|null
*/
public function getLongitude()
{
return $this->longitude;
}
/**
* Get latitude
*
* @return mixed|null
*/
public function getLatitude()
{
return $this->latitude;
}
}
This diff is collapsed.
This diff is collapsed.
......@@ -10,94 +10,17 @@
namespace Longman\TelegramBot\Entities;
use Longman\TelegramBot\Exception\TelegramException;
/**
* Class PhotoSize
*
* @link https://core.telegram.org/bots/api#photosize
*
* @method string getFileId() Unique identifier for this file
* @method int getWidth() Photo width
* @method int getHeight() Photo height
* @method int getFileSize() Optional. File size
*/
class PhotoSize extends Entity
{
/**
* @var mixed|null
*/
protected $file_id;
/**
* @var mixed|null
*/
protected $width;
/**
* @var mixed|null
*/
protected $height;
/**
* @var mixed|null
*/
protected $file_size;
/**
* PhotoSize constructor.
*
* @param array $data
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function __construct(array $data)
{
$this->file_id = isset($data['file_id']) ? $data['file_id'] : null;
if (empty($this->file_id)) {
throw new TelegramException('file_id is empty!');
}
$this->width = isset($data['width']) ? $data['width'] : null;
if (empty($this->width)) {
throw new TelegramException('width is empty!');
}
$this->height = isset($data['height']) ? $data['height'] : null;
if (empty($this->height)) {
throw new TelegramException('height is empty!');
}
$this->file_size = isset($data['file_size']) ? $data['file_size'] : null;
}
/**
* Get file id
*
* @return mixed|null
*/
public function getFileId()
{
return $this->file_id;
}
/**
* Get width
*
* @return mixed|null
*/
public function getWidth()
{
return $this->width;
}
/**
* Get height
*
* @return mixed|null
*/
public function getHeight()
{
return $this->height;
}
/**
* Get file size
*
* @return mixed|null
*/
public function getFileSize()
{
return $this->file_size;
}
}
......@@ -19,7 +19,7 @@ class ReplyToMessage extends Message
* @param array $data
* @param string $bot_name
*/
public function __construct(array $data, $bot_name)
public function __construct(array $data, $bot_name = '')
{
//As explained in the documentation
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment