From aa7296e988baca54bc1a7d45fe14cf9832e2e231 Mon Sep 17 00:00:00 2001 From: Netkas Date: Mon, 13 Feb 2023 17:53:32 -0500 Subject: [PATCH] Added \TgBotLib\Objects > ChatMember > ChatMemberBanned --- .../Objects/ChatMember/ChatMemberBanned.php | 103 ++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 src/TgBotLib/Objects/ChatMember/ChatMemberBanned.php diff --git a/src/TgBotLib/Objects/ChatMember/ChatMemberBanned.php b/src/TgBotLib/Objects/ChatMember/ChatMemberBanned.php new file mode 100644 index 0000000..163845c --- /dev/null +++ b/src/TgBotLib/Objects/ChatMember/ChatMemberBanned.php @@ -0,0 +1,103 @@ +status; + } + + /** + * Information about the user + * + * @return User + */ + public function getUser(): User + { + return $this->user; + } + + /** + * Date when restrictions will be lifted for this user; unix time. If 0, then the user is banned forever + * + * @return int + */ + public function getUntilDate(): int + { + return $this->until_date; + } + + /** + * Returns an array representation of the object + * + * @return array + */ + public function toArray(): array + { + return [ + 'status' => $this->status, + 'user' => ($this->user instanceof ObjectTypeInterface) ? $this->user->toArray() : $this->user, + 'until_date' => $this->until_date + ]; + } + + /** + * Constructs object from an array representation + * + * @param array $data + * @return ObjectTypeInterface + */ + public static function fromArray(array $data): ObjectTypeInterface + { + $object = new self(); + $object->status = $data['status']; + $object->user = isset($data['user']) ? User::fromArray($data['user']) : null; + $object->until_date = $data['until_date']; + + return $object; + } + + /** + * Constructs object from a ChatMember object + * + * @param ChatMember $chatMember + * @return ChatMemberBanned + */ + public static function fromChatMember(ChatMember $chatMember): ChatMemberBanned + { + $object = new self(); + $object->status = $chatMember->getStatus(); + $object->user = $chatMember->getUser(); + $object->until_date = $chatMember->getUntilDate(); + + return $object; + } + } \ No newline at end of file