diff --git a/src/TgBotLib/Objects/ChatMember/ChatMemberLeft.php b/src/TgBotLib/Objects/ChatMember/ChatMemberLeft.php new file mode 100644 index 0000000..4231ae8 --- /dev/null +++ b/src/TgBotLib/Objects/ChatMember/ChatMemberLeft.php @@ -0,0 +1,81 @@ +status; + } + + /** + * Information about the user + * + * @return User + */ + public function getUser(): User + { + return $this->user; + } + + /** + * 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, + ]; + } + + /** + * Constructs the 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 = User::fromArray($data['user']); + return $object; + } + + /** + * Constructs the object from ChatMember object + * + * @param ChatMember $chatMember + * @return static + */ + public static function fromChatMember(ChatMember $chatMember): self + { + $object = new self(); + $object->status = $chatMember->getStatus(); + $object->user = $chatMember->getUser(); + return $object; + } + } \ No newline at end of file