From 1c1725fbf6b985ab63dc0957bc73e1a06c470f6c Mon Sep 17 00:00:00 2001 From: Netkas Date: Sun, 12 Feb 2023 18:36:33 -0500 Subject: [PATCH] Added \TgBotLib\Objects > ProximityAlertTriggered --- .../Objects/ProximityAlertTriggered.php | 83 +++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 src/TgBotLib/Objects/ProximityAlertTriggered.php diff --git a/src/TgBotLib/Objects/ProximityAlertTriggered.php b/src/TgBotLib/Objects/ProximityAlertTriggered.php new file mode 100644 index 0000000..29c165a --- /dev/null +++ b/src/TgBotLib/Objects/ProximityAlertTriggered.php @@ -0,0 +1,83 @@ +traveler; + } + + /** + * User that set the alert + * + * @return User + */ + public function getWatcher(): User + { + return $this->watcher; + } + + /** + * The distance between the users + * + * @return int + */ + public function getDistance(): int + { + return $this->distance; + } + + /** + * Returns an array representation of the object. + * + * @return array + */ + public function toArray(): array + { + return [ + 'traveler' => ($this->traveler instanceof ObjectTypeInterface) ? $this->traveler->toArray() : $this->traveler, + 'watcher' => ($this->watcher instanceof ObjectTypeInterface) ? $this->watcher->toArray() : $this->watcher, + 'distance' => $this->distance, + ]; + } + + /** + * Constructs the object from an array representation. + * + * @param array $data + * @return ObjectTypeInterface + */ + public static function fromArray(array $data): ObjectTypeInterface + { + $object = new self(); + $object->traveler = User::fromArray($data['traveler']); + $object->watcher = User::fromArray($data['watcher']); + $object->distance = $data['distance']; + + return $object; + } + } \ No newline at end of file