From 7b54b8572d331c0e6275c798e45a08799b162291 Mon Sep 17 00:00:00 2001 From: netkas Date: Fri, 4 Oct 2024 14:56:02 -0400 Subject: [PATCH] Updated ChatLocation --- src/TgBotLib/Objects/ChatLocation.php | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/src/TgBotLib/Objects/ChatLocation.php b/src/TgBotLib/Objects/ChatLocation.php index 8d87930..9dfc9a8 100644 --- a/src/TgBotLib/Objects/ChatLocation.php +++ b/src/TgBotLib/Objects/ChatLocation.php @@ -7,15 +7,8 @@ class ChatLocation implements ObjectTypeInterface { - /** - * @var Location - */ - private $location; - - /** - * @var string - */ - private $address; + private Location $location; + private string $address; /** * The location to which the supergroup is connected. Can't be a live location. @@ -38,28 +31,22 @@ } /** - * Returns an array representation of the object - * - * @return array + * @inheritDoc */ public function toArray(): array { return [ - 'location' => ($this->location instanceof ObjectTypeInterface) ? $this->location->toArray() : $this->location, + 'location' => $this->location?->toArray(), 'address' => $this->address, ]; } /** - * Constructs object from an array representation - * - * @param array $data - * @return ChatLocation + * @inheritDoc */ - public static function fromArray(array $data): self + public static function fromArray(?array $data): ChatLocation { $object = new self(); - $object->location = isset($data['location']) ? Location::fromArray($data['location']) : null; $object->address = $data['address'] ?? null;