@@ -23,103 +23,103 @@ |
||
| 23 | 23 | class Keyboard extends Entity |
| 24 | 24 | { |
| 25 | 25 | |
| 26 | - public function __construct(array $data = []) |
|
| 27 | - { |
|
| 28 | - parent::__construct(array_merge($data, [ |
|
| 29 | - 'resize_keyboard' => false, |
|
| 30 | - 'one_time_keyboard' => false, |
|
| 31 | - 'input_field_placeholder' => '', |
|
| 32 | - 'selective' => false |
|
| 33 | - ])); |
|
| 34 | - } |
|
| 35 | - |
|
| 36 | - /** |
|
| 37 | - * Create a new row in keyboard and add buttons. |
|
| 38 | - * |
|
| 39 | - * @param array<KeyboardButton> $row |
|
| 40 | - * @return Keyboard |
|
| 41 | - */ |
|
| 42 | - public function addRow(array $row): Keyboard |
|
| 43 | - { |
|
| 44 | - $keyboard_type = self::getType(); |
|
| 45 | - |
|
| 46 | - if (!isset($this->raw_data[$keyboard_type]) || !is_array($this->raw_data[$keyboard_type])) { |
|
| 47 | - $this->raw_data[$keyboard_type] = []; |
|
| 48 | - } |
|
| 49 | - |
|
| 50 | - $new_row = []; |
|
| 51 | - foreach ($row as $button) { |
|
| 52 | - $new_row[] = $button->getRawData(); |
|
| 53 | - } |
|
| 54 | - |
|
| 55 | - $this->raw_data[$keyboard_type][] = $new_row; |
|
| 56 | - |
|
| 57 | - return $this; |
|
| 58 | - } |
|
| 59 | - |
|
| 60 | - /** |
|
| 61 | - * Remove the current custom keyboard and display the default letter-keyboard. |
|
| 62 | - * |
|
| 63 | - * @link https://core.telegram.org/bots/api/#replykeyboardremove |
|
| 64 | - * |
|
| 65 | - * @param array $data |
|
| 66 | - * |
|
| 67 | - * @return Keyboard |
|
| 68 | - */ |
|
| 69 | - public static function remove(array $data = []): Keyboard |
|
| 70 | - { |
|
| 71 | - return new static(array_merge(['keyboard' => [], 'remove_keyboard' => true, 'selective' => false], $data)); |
|
| 72 | - } |
|
| 73 | - |
|
| 74 | - /** |
|
| 75 | - * Display a reply interface to the user (act as if the user has selected the bot's message and tapped 'Reply'). |
|
| 76 | - * |
|
| 77 | - * @link https://core.telegram.org/bots/api#forcereply |
|
| 78 | - * |
|
| 79 | - * @param array $data |
|
| 80 | - * |
|
| 81 | - * @return Keyboard |
|
| 82 | - */ |
|
| 83 | - public static function forceReply(array $data = []): Keyboard |
|
| 84 | - { |
|
| 85 | - return new static(array_merge(['keyboard' => [], 'force_reply' => true, 'selective' => false], $data)); |
|
| 86 | - } |
|
| 87 | - |
|
| 88 | - /** |
|
| 89 | - * Get keyboard button type |
|
| 90 | - * |
|
| 91 | - * @return string ["keyboard"|"inline_keyboard"] |
|
| 92 | - */ |
|
| 93 | - public function getType(): string |
|
| 94 | - { |
|
| 95 | - $reflection = new \ReflectionClass(static::class); |
|
| 96 | - |
|
| 97 | - $class_name = $reflection->getShortName(); |
|
| 98 | - |
|
| 99 | - return strtolower(ltrim(preg_replace('/[A-Z]/', '_$0', $class_name), '_')); |
|
| 100 | - } |
|
| 101 | - |
|
| 102 | - /** |
|
| 103 | - * Creates instance of Keyboard |
|
| 104 | - * |
|
| 105 | - * @return Keyboard |
|
| 106 | - */ |
|
| 107 | - public static function make(): Keyboard |
|
| 108 | - { |
|
| 109 | - return new self(); |
|
| 110 | - } |
|
| 111 | - |
|
| 112 | - /** |
|
| 113 | - * @param array $rows |
|
| 114 | - * @return Keyboard |
|
| 115 | - */ |
|
| 116 | - public function setKeyboard(array $rows): Keyboard |
|
| 117 | - { |
|
| 118 | - foreach ($rows as $row) { |
|
| 119 | - $this->addRow($row); |
|
| 120 | - } |
|
| 121 | - |
|
| 122 | - return $this; |
|
| 123 | - } |
|
| 26 | + public function __construct(array $data = []) |
|
| 27 | + { |
|
| 28 | + parent::__construct(array_merge($data, [ |
|
| 29 | + 'resize_keyboard' => false, |
|
| 30 | + 'one_time_keyboard' => false, |
|
| 31 | + 'input_field_placeholder' => '', |
|
| 32 | + 'selective' => false |
|
| 33 | + ])); |
|
| 34 | + } |
|
| 35 | + |
|
| 36 | + /** |
|
| 37 | + * Create a new row in keyboard and add buttons. |
|
| 38 | + * |
|
| 39 | + * @param array<KeyboardButton> $row |
|
| 40 | + * @return Keyboard |
|
| 41 | + */ |
|
| 42 | + public function addRow(array $row): Keyboard |
|
| 43 | + { |
|
| 44 | + $keyboard_type = self::getType(); |
|
| 45 | + |
|
| 46 | + if (!isset($this->raw_data[$keyboard_type]) || !is_array($this->raw_data[$keyboard_type])) { |
|
| 47 | + $this->raw_data[$keyboard_type] = []; |
|
| 48 | + } |
|
| 49 | + |
|
| 50 | + $new_row = []; |
|
| 51 | + foreach ($row as $button) { |
|
| 52 | + $new_row[] = $button->getRawData(); |
|
| 53 | + } |
|
| 54 | + |
|
| 55 | + $this->raw_data[$keyboard_type][] = $new_row; |
|
| 56 | + |
|
| 57 | + return $this; |
|
| 58 | + } |
|
| 59 | + |
|
| 60 | + /** |
|
| 61 | + * Remove the current custom keyboard and display the default letter-keyboard. |
|
| 62 | + * |
|
| 63 | + * @link https://core.telegram.org/bots/api/#replykeyboardremove |
|
| 64 | + * |
|
| 65 | + * @param array $data |
|
| 66 | + * |
|
| 67 | + * @return Keyboard |
|
| 68 | + */ |
|
| 69 | + public static function remove(array $data = []): Keyboard |
|
| 70 | + { |
|
| 71 | + return new static(array_merge(['keyboard' => [], 'remove_keyboard' => true, 'selective' => false], $data)); |
|
| 72 | + } |
|
| 73 | + |
|
| 74 | + /** |
|
| 75 | + * Display a reply interface to the user (act as if the user has selected the bot's message and tapped 'Reply'). |
|
| 76 | + * |
|
| 77 | + * @link https://core.telegram.org/bots/api#forcereply |
|
| 78 | + * |
|
| 79 | + * @param array $data |
|
| 80 | + * |
|
| 81 | + * @return Keyboard |
|
| 82 | + */ |
|
| 83 | + public static function forceReply(array $data = []): Keyboard |
|
| 84 | + { |
|
| 85 | + return new static(array_merge(['keyboard' => [], 'force_reply' => true, 'selective' => false], $data)); |
|
| 86 | + } |
|
| 87 | + |
|
| 88 | + /** |
|
| 89 | + * Get keyboard button type |
|
| 90 | + * |
|
| 91 | + * @return string ["keyboard"|"inline_keyboard"] |
|
| 92 | + */ |
|
| 93 | + public function getType(): string |
|
| 94 | + { |
|
| 95 | + $reflection = new \ReflectionClass(static::class); |
|
| 96 | + |
|
| 97 | + $class_name = $reflection->getShortName(); |
|
| 98 | + |
|
| 99 | + return strtolower(ltrim(preg_replace('/[A-Z]/', '_$0', $class_name), '_')); |
|
| 100 | + } |
|
| 101 | + |
|
| 102 | + /** |
|
| 103 | + * Creates instance of Keyboard |
|
| 104 | + * |
|
| 105 | + * @return Keyboard |
|
| 106 | + */ |
|
| 107 | + public static function make(): Keyboard |
|
| 108 | + { |
|
| 109 | + return new self(); |
|
| 110 | + } |
|
| 111 | + |
|
| 112 | + /** |
|
| 113 | + * @param array $rows |
|
| 114 | + * @return Keyboard |
|
| 115 | + */ |
|
| 116 | + public function setKeyboard(array $rows): Keyboard |
|
| 117 | + { |
|
| 118 | + foreach ($rows as $row) { |
|
| 119 | + $this->addRow($row); |
|
| 120 | + } |
|
| 121 | + |
|
| 122 | + return $this; |
|
| 123 | + } |
|
| 124 | 124 | |
| 125 | 125 | } |
@@ -32,70 +32,70 @@ |
||
| 32 | 32 | class Update extends Entity |
| 33 | 33 | { |
| 34 | 34 | |
| 35 | - public const TYPE_MESSAGE = 'message'; |
|
| 36 | - public const TYPE_EDITED_MESSAGE = 'edited_message'; |
|
| 37 | - public const TYPE_CHANNEL_POST = 'channel_post'; |
|
| 38 | - public const TYPE_EDITED_CHANNEL_POST = 'edited_channel_post'; |
|
| 39 | - public const TYPE_INLINE_QUERY = 'inline_query'; |
|
| 40 | - public const TYPE_CHOSEN_INLINE_RESULT = 'chosen_inline_result'; |
|
| 41 | - public const TYPE_CALLBACK_QUERY = 'callback_query'; |
|
| 42 | - public const TYPE_SHIPPING_QUERY = 'shipping_query'; |
|
| 43 | - public const TYPE_PRE_CHECKOUT_QUERY = 'pre_checkout_query'; |
|
| 44 | - public const TYPE_POLL = 'poll'; |
|
| 45 | - public const TYPE_POLL_ANSWER = 'poll_answer'; |
|
| 46 | - public const TYPE_MY_CHAT_MEMBER = 'my_chat_member'; |
|
| 47 | - public const TYPE_CHAT_MEMBER = 'chat_member'; |
|
| 48 | - public const TYPE_CHAT_JOIN_REQUEST = 'chat_join_request'; |
|
| 49 | - public const TYPE_WEB_DATA = 'web_data'; |
|
| 35 | + public const TYPE_MESSAGE = 'message'; |
|
| 36 | + public const TYPE_EDITED_MESSAGE = 'edited_message'; |
|
| 37 | + public const TYPE_CHANNEL_POST = 'channel_post'; |
|
| 38 | + public const TYPE_EDITED_CHANNEL_POST = 'edited_channel_post'; |
|
| 39 | + public const TYPE_INLINE_QUERY = 'inline_query'; |
|
| 40 | + public const TYPE_CHOSEN_INLINE_RESULT = 'chosen_inline_result'; |
|
| 41 | + public const TYPE_CALLBACK_QUERY = 'callback_query'; |
|
| 42 | + public const TYPE_SHIPPING_QUERY = 'shipping_query'; |
|
| 43 | + public const TYPE_PRE_CHECKOUT_QUERY = 'pre_checkout_query'; |
|
| 44 | + public const TYPE_POLL = 'poll'; |
|
| 45 | + public const TYPE_POLL_ANSWER = 'poll_answer'; |
|
| 46 | + public const TYPE_MY_CHAT_MEMBER = 'my_chat_member'; |
|
| 47 | + public const TYPE_CHAT_MEMBER = 'chat_member'; |
|
| 48 | + public const TYPE_CHAT_JOIN_REQUEST = 'chat_join_request'; |
|
| 49 | + public const TYPE_WEB_DATA = 'web_data'; |
|
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * {@inheritdoc} |
|
| 53 | - */ |
|
| 54 | - protected function subEntities(): array |
|
| 55 | - { |
|
| 56 | - return [ |
|
| 57 | - self::TYPE_MESSAGE => Message::class, |
|
| 58 | - self::TYPE_EDITED_MESSAGE => EditedMessage::class, |
|
| 59 | - self::TYPE_CHANNEL_POST => ChannelPost::class, |
|
| 60 | - self::TYPE_EDITED_CHANNEL_POST => EditedChannelPost::class, |
|
| 61 | - self::TYPE_INLINE_QUERY => InlineQuery::class, |
|
| 62 | - self::TYPE_CHOSEN_INLINE_RESULT => ChosenInlineResult::class, |
|
| 63 | - self::TYPE_CALLBACK_QUERY => CallbackQuery::class, |
|
| 64 | - self::TYPE_SHIPPING_QUERY => ShippingQuery::class, |
|
| 65 | - self::TYPE_PRE_CHECKOUT_QUERY => PreCheckoutQuery::class, |
|
| 66 | - self::TYPE_POLL => Poll::class, |
|
| 67 | - self::TYPE_POLL_ANSWER => PollAnswer::class, |
|
| 68 | - self::TYPE_MY_CHAT_MEMBER => ChatMemberUpdated::class, |
|
| 69 | - self::TYPE_CHAT_MEMBER => ChatMemberUpdated::class, |
|
| 70 | - self::TYPE_CHAT_JOIN_REQUEST => ChatJoinRequest::class, |
|
| 71 | - self::TYPE_WEB_DATA => WebAppData::class, |
|
| 72 | - ]; |
|
| 73 | - } |
|
| 51 | + /** |
|
| 52 | + * {@inheritdoc} |
|
| 53 | + */ |
|
| 54 | + protected function subEntities(): array |
|
| 55 | + { |
|
| 56 | + return [ |
|
| 57 | + self::TYPE_MESSAGE => Message::class, |
|
| 58 | + self::TYPE_EDITED_MESSAGE => EditedMessage::class, |
|
| 59 | + self::TYPE_CHANNEL_POST => ChannelPost::class, |
|
| 60 | + self::TYPE_EDITED_CHANNEL_POST => EditedChannelPost::class, |
|
| 61 | + self::TYPE_INLINE_QUERY => InlineQuery::class, |
|
| 62 | + self::TYPE_CHOSEN_INLINE_RESULT => ChosenInlineResult::class, |
|
| 63 | + self::TYPE_CALLBACK_QUERY => CallbackQuery::class, |
|
| 64 | + self::TYPE_SHIPPING_QUERY => ShippingQuery::class, |
|
| 65 | + self::TYPE_PRE_CHECKOUT_QUERY => PreCheckoutQuery::class, |
|
| 66 | + self::TYPE_POLL => Poll::class, |
|
| 67 | + self::TYPE_POLL_ANSWER => PollAnswer::class, |
|
| 68 | + self::TYPE_MY_CHAT_MEMBER => ChatMemberUpdated::class, |
|
| 69 | + self::TYPE_CHAT_MEMBER => ChatMemberUpdated::class, |
|
| 70 | + self::TYPE_CHAT_JOIN_REQUEST => ChatJoinRequest::class, |
|
| 71 | + self::TYPE_WEB_DATA => WebAppData::class, |
|
| 72 | + ]; |
|
| 73 | + } |
|
| 74 | 74 | |
| 75 | - /** |
|
| 76 | - * Get the list of all available update types |
|
| 77 | - * |
|
| 78 | - * @return string[] |
|
| 79 | - */ |
|
| 80 | - public static function getUpdateTypes(): array |
|
| 81 | - { |
|
| 82 | - return array_keys((new self([]))->subEntities()); |
|
| 83 | - } |
|
| 75 | + /** |
|
| 76 | + * Get the list of all available update types |
|
| 77 | + * |
|
| 78 | + * @return string[] |
|
| 79 | + */ |
|
| 80 | + public static function getUpdateTypes(): array |
|
| 81 | + { |
|
| 82 | + return array_keys((new self([]))->subEntities()); |
|
| 83 | + } |
|
| 84 | 84 | |
| 85 | - /** |
|
| 86 | - * Get the update type based on the set properties |
|
| 87 | - * |
|
| 88 | - * @return string|null |
|
| 89 | - */ |
|
| 90 | - public function getUpdateType(): ?string |
|
| 91 | - { |
|
| 92 | - foreach (self::getUpdateTypes() as $type) { |
|
| 93 | - if ($this->getProperty($type)) { |
|
| 94 | - return $type; |
|
| 95 | - } |
|
| 96 | - } |
|
| 85 | + /** |
|
| 86 | + * Get the update type based on the set properties |
|
| 87 | + * |
|
| 88 | + * @return string|null |
|
| 89 | + */ |
|
| 90 | + public function getUpdateType(): ?string |
|
| 91 | + { |
|
| 92 | + foreach (self::getUpdateTypes() as $type) { |
|
| 93 | + if ($this->getProperty($type)) { |
|
| 94 | + return $type; |
|
| 95 | + } |
|
| 96 | + } |
|
| 97 | 97 | |
| 98 | - return null; |
|
| 99 | - } |
|
| 98 | + return null; |
|
| 99 | + } |
|
| 100 | 100 | |
| 101 | 101 | } |
@@ -35,49 +35,49 @@ |
||
| 35 | 35 | class InlineKeyboardButton extends KeyboardButton |
| 36 | 36 | { |
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * Creates instance of InlineKeyboardButton |
|
| 40 | - * |
|
| 41 | - * @param string $string |
|
| 42 | - * @return InlineKeyboardButton |
|
| 43 | - */ |
|
| 44 | - public static function make(string $string): InlineKeyboardButton |
|
| 45 | - { |
|
| 46 | - return new self($string); |
|
| 47 | - } |
|
| 38 | + /** |
|
| 39 | + * Creates instance of InlineKeyboardButton |
|
| 40 | + * |
|
| 41 | + * @param string $string |
|
| 42 | + * @return InlineKeyboardButton |
|
| 43 | + */ |
|
| 44 | + public static function make(string $string): InlineKeyboardButton |
|
| 45 | + { |
|
| 46 | + return new self($string); |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - /** |
|
| 50 | - * @param string $data |
|
| 51 | - * @return $this |
|
| 52 | - */ |
|
| 53 | - public function CallbackData(string $data): InlineKeyboardButton |
|
| 54 | - { |
|
| 55 | - $this->raw_data['callback_data'] = $data; |
|
| 49 | + /** |
|
| 50 | + * @param string $data |
|
| 51 | + * @return $this |
|
| 52 | + */ |
|
| 53 | + public function CallbackData(string $data): InlineKeyboardButton |
|
| 54 | + { |
|
| 55 | + $this->raw_data['callback_data'] = $data; |
|
| 56 | 56 | |
| 57 | - return $this; |
|
| 58 | - } |
|
| 57 | + return $this; |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | - /** |
|
| 61 | - * @param string $data |
|
| 62 | - * @return $this |
|
| 63 | - */ |
|
| 64 | - public function Url(string $data): InlineKeyboardButton |
|
| 65 | - { |
|
| 66 | - $this->raw_data['url'] = $data; |
|
| 60 | + /** |
|
| 61 | + * @param string $data |
|
| 62 | + * @return $this |
|
| 63 | + */ |
|
| 64 | + public function Url(string $data): InlineKeyboardButton |
|
| 65 | + { |
|
| 66 | + $this->raw_data['url'] = $data; |
|
| 67 | 67 | |
| 68 | - return $this; |
|
| 69 | - } |
|
| 68 | + return $this; |
|
| 69 | + } |
|
| 70 | 70 | |
| 71 | - /** |
|
| 72 | - * @param string $url |
|
| 73 | - * @return $this |
|
| 74 | - */ |
|
| 75 | - public function WebApp(string $url): KeyboardButton |
|
| 76 | - { |
|
| 77 | - $this->raw_data['web_app'] = new WebAppInfo(['url' => $url]); |
|
| 71 | + /** |
|
| 72 | + * @param string $url |
|
| 73 | + * @return $this |
|
| 74 | + */ |
|
| 75 | + public function WebApp(string $url): KeyboardButton |
|
| 76 | + { |
|
| 77 | + $this->raw_data['web_app'] = new WebAppInfo(['url' => $url]); |
|
| 78 | 78 | |
| 79 | - return $this; |
|
| 80 | - } |
|
| 79 | + return $this; |
|
| 80 | + } |
|
| 81 | 81 | |
| 82 | 82 | /** |
| 83 | 83 | * Check if the passed data array could be an InlineKeyboardButton. |
@@ -12,63 +12,63 @@ |
||
| 12 | 12 | class Common |
| 13 | 13 | { |
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * Validate the given string is JSON or not |
|
| 17 | - * |
|
| 18 | - * @param ?string $string |
|
| 19 | - * @return bool |
|
| 20 | - */ |
|
| 21 | - public static function isJson(?string $string): bool |
|
| 22 | - { |
|
| 23 | - if (!is_string($string)) { |
|
| 24 | - return false; |
|
| 25 | - } |
|
| 15 | + /** |
|
| 16 | + * Validate the given string is JSON or not |
|
| 17 | + * |
|
| 18 | + * @param ?string $string |
|
| 19 | + * @return bool |
|
| 20 | + */ |
|
| 21 | + public static function isJson(?string $string): bool |
|
| 22 | + { |
|
| 23 | + if (!is_string($string)) { |
|
| 24 | + return false; |
|
| 25 | + } |
|
| 26 | 26 | |
| 27 | - json_decode($string); |
|
| 27 | + json_decode($string); |
|
| 28 | 28 | |
| 29 | - return json_last_error() === JSON_ERROR_NONE; |
|
| 30 | - } |
|
| 29 | + return json_last_error() === JSON_ERROR_NONE; |
|
| 30 | + } |
|
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * Check string is a url encoded string or not |
|
| 34 | - * |
|
| 35 | - * @param ?string $string |
|
| 36 | - * @return bool |
|
| 37 | - */ |
|
| 38 | - public static function isUrlEncode(?string $string): bool |
|
| 39 | - { |
|
| 40 | - if (!is_string($string)) { |
|
| 41 | - return false; |
|
| 42 | - } |
|
| 32 | + /** |
|
| 33 | + * Check string is a url encoded string or not |
|
| 34 | + * |
|
| 35 | + * @param ?string $string |
|
| 36 | + * @return bool |
|
| 37 | + */ |
|
| 38 | + public static function isUrlEncode(?string $string): bool |
|
| 39 | + { |
|
| 40 | + if (!is_string($string)) { |
|
| 41 | + return false; |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | - return preg_match('/%[0-9A-F]{2}/i', $string); |
|
| 45 | - } |
|
| 44 | + return preg_match('/%[0-9A-F]{2}/i', $string); |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * Convert url encoded string to array |
|
| 49 | - * |
|
| 50 | - * @param string $string |
|
| 51 | - * @return array |
|
| 52 | - */ |
|
| 53 | - public static function urlDecode(string $string): array |
|
| 54 | - { |
|
| 55 | - $raw_data = explode('&', urldecode($string)); |
|
| 56 | - $data = []; |
|
| 47 | + /** |
|
| 48 | + * Convert url encoded string to array |
|
| 49 | + * |
|
| 50 | + * @param string $string |
|
| 51 | + * @return array |
|
| 52 | + */ |
|
| 53 | + public static function urlDecode(string $string): array |
|
| 54 | + { |
|
| 55 | + $raw_data = explode('&', urldecode($string)); |
|
| 56 | + $data = []; |
|
| 57 | 57 | |
| 58 | - foreach ($raw_data as $row) { |
|
| 59 | - [$key, $value] = explode('=', $row); |
|
| 58 | + foreach ($raw_data as $row) { |
|
| 59 | + [$key, $value] = explode('=', $row); |
|
| 60 | 60 | |
| 61 | - if (self::isUrlEncode($value)) { |
|
| 62 | - $value = urldecode($value); |
|
| 63 | - if (self::isJson($value)) { |
|
| 64 | - $value = json_decode($value, true); |
|
| 65 | - } |
|
| 66 | - } |
|
| 61 | + if (self::isUrlEncode($value)) { |
|
| 62 | + $value = urldecode($value); |
|
| 63 | + if (self::isJson($value)) { |
|
| 64 | + $value = json_decode($value, true); |
|
| 65 | + } |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - $data[$key] = $value; |
|
| 69 | - } |
|
| 68 | + $data[$key] = $value; |
|
| 69 | + } |
|
| 70 | 70 | |
| 71 | - return $data; |
|
| 72 | - } |
|
| 71 | + return $data; |
|
| 72 | + } |
|
| 73 | 73 | |
| 74 | 74 | } |
| 75 | 75 | \ No newline at end of file |
@@ -23,18 +23,18 @@ |
||
| 23 | 23 | class ChatMemberUpdated extends Entity |
| 24 | 24 | { |
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * {@inheritdoc} |
|
| 28 | - */ |
|
| 29 | - protected function subEntities(): array |
|
| 30 | - { |
|
| 31 | - return [ |
|
| 32 | - 'chat' => Chat::class, |
|
| 33 | - 'from' => User::class, |
|
| 34 | - 'old_chat_member' => ChatMemberFactory::class, |
|
| 35 | - 'new_chat_member' => ChatMemberFactory::class, |
|
| 36 | - 'invite_link' => ChatInviteLink::class, |
|
| 37 | - ]; |
|
| 38 | - } |
|
| 26 | + /** |
|
| 27 | + * {@inheritdoc} |
|
| 28 | + */ |
|
| 29 | + protected function subEntities(): array |
|
| 30 | + { |
|
| 31 | + return [ |
|
| 32 | + 'chat' => Chat::class, |
|
| 33 | + 'from' => User::class, |
|
| 34 | + 'old_chat_member' => ChatMemberFactory::class, |
|
| 35 | + 'new_chat_member' => ChatMemberFactory::class, |
|
| 36 | + 'invite_link' => ChatInviteLink::class, |
|
| 37 | + ]; |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | 40 | } |
@@ -15,36 +15,36 @@ |
||
| 15 | 15 | class UserProfilePhotos extends Entity |
| 16 | 16 | { |
| 17 | 17 | |
| 18 | - /** |
|
| 19 | - * {@inheritdoc} |
|
| 20 | - */ |
|
| 21 | - protected function subEntities(): array |
|
| 22 | - { |
|
| 23 | - return [ |
|
| 24 | - 'photos' => PhotoSize::class, |
|
| 25 | - ]; |
|
| 26 | - } |
|
| 27 | - |
|
| 28 | - /** |
|
| 29 | - * Requested profile pictures (in up to 4 sizes each) |
|
| 30 | - * |
|
| 31 | - * This method overrides the default getPhotos method and returns a nice array |
|
| 32 | - * |
|
| 33 | - * @return PhotoSize[][] |
|
| 34 | - */ |
|
| 35 | - public function getPhotos(): array |
|
| 36 | - { |
|
| 37 | - $all_photos = []; |
|
| 38 | - |
|
| 39 | - if ($these_photos = $this->getProperty('photos')) { |
|
| 40 | - foreach ($these_photos as $photos) { |
|
| 41 | - $all_photos[] = array_map(function ($photo) { |
|
| 42 | - return new PhotoSize($photo); |
|
| 43 | - }, $photos); |
|
| 44 | - } |
|
| 45 | - } |
|
| 46 | - |
|
| 47 | - return $all_photos; |
|
| 48 | - } |
|
| 18 | + /** |
|
| 19 | + * {@inheritdoc} |
|
| 20 | + */ |
|
| 21 | + protected function subEntities(): array |
|
| 22 | + { |
|
| 23 | + return [ |
|
| 24 | + 'photos' => PhotoSize::class, |
|
| 25 | + ]; |
|
| 26 | + } |
|
| 27 | + |
|
| 28 | + /** |
|
| 29 | + * Requested profile pictures (in up to 4 sizes each) |
|
| 30 | + * |
|
| 31 | + * This method overrides the default getPhotos method and returns a nice array |
|
| 32 | + * |
|
| 33 | + * @return PhotoSize[][] |
|
| 34 | + */ |
|
| 35 | + public function getPhotos(): array |
|
| 36 | + { |
|
| 37 | + $all_photos = []; |
|
| 38 | + |
|
| 39 | + if ($these_photos = $this->getProperty('photos')) { |
|
| 40 | + foreach ($these_photos as $photos) { |
|
| 41 | + $all_photos[] = array_map(function ($photo) { |
|
| 42 | + return new PhotoSize($photo); |
|
| 43 | + }, $photos); |
|
| 44 | + } |
|
| 45 | + } |
|
| 46 | + |
|
| 47 | + return $all_photos; |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | 50 | } |
@@ -38,7 +38,7 @@ |
||
| 38 | 38 | |
| 39 | 39 | if ($these_photos = $this->getProperty('photos')) { |
| 40 | 40 | foreach ($these_photos as $photos) { |
| 41 | - $all_photos[] = array_map(function ($photo) { |
|
| 41 | + $all_photos[] = array_map(function($photo) { |
|
| 42 | 42 | return new PhotoSize($photo); |
| 43 | 43 | }, $photos); |
| 44 | 44 | } |
@@ -14,14 +14,14 @@ |
||
| 14 | 14 | class VideoChatParticipantsInvited extends Entity |
| 15 | 15 | { |
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * {@inheritdoc} |
|
| 19 | - */ |
|
| 20 | - protected function subEntities(): array |
|
| 21 | - { |
|
| 22 | - return [ |
|
| 23 | - 'users' => [User::class], |
|
| 24 | - ]; |
|
| 25 | - } |
|
| 17 | + /** |
|
| 18 | + * {@inheritdoc} |
|
| 19 | + */ |
|
| 20 | + protected function subEntities(): array |
|
| 21 | + { |
|
| 22 | + return [ |
|
| 23 | + 'users' => [User::class], |
|
| 24 | + ]; |
|
| 25 | + } |
|
| 26 | 26 | |
| 27 | 27 | } |
@@ -20,14 +20,14 @@ |
||
| 20 | 20 | class VideoNote extends Entity |
| 21 | 21 | { |
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * {@inheritdoc} |
|
| 25 | - */ |
|
| 26 | - protected function subEntities(): array |
|
| 27 | - { |
|
| 28 | - return [ |
|
| 29 | - 'thumb' => PhotoSize::class, |
|
| 30 | - ]; |
|
| 31 | - } |
|
| 23 | + /** |
|
| 24 | + * {@inheritdoc} |
|
| 25 | + */ |
|
| 26 | + protected function subEntities(): array |
|
| 27 | + { |
|
| 28 | + return [ |
|
| 29 | + 'thumb' => PhotoSize::class, |
|
| 30 | + ]; |
|
| 31 | + } |
|
| 32 | 32 | |
| 33 | 33 | } |
@@ -21,14 +21,14 @@ |
||
| 21 | 21 | class Venue extends Entity |
| 22 | 22 | { |
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * {@inheritdoc} |
|
| 26 | - */ |
|
| 27 | - protected function subEntities(): array |
|
| 28 | - { |
|
| 29 | - return [ |
|
| 30 | - 'location' => Location::class, |
|
| 31 | - ]; |
|
| 32 | - } |
|
| 24 | + /** |
|
| 25 | + * {@inheritdoc} |
|
| 26 | + */ |
|
| 27 | + protected function subEntities(): array |
|
| 28 | + { |
|
| 29 | + return [ |
|
| 30 | + 'location' => Location::class, |
|
| 31 | + ]; |
|
| 32 | + } |
|
| 33 | 33 | |
| 34 | 34 | } |