From 78447603e467badde477ed417fcdb43f515a335a Mon Sep 17 00:00:00 2001 From: Netkas Date: Sun, 12 Feb 2023 17:40:07 -0500 Subject: [PATCH] Added \TgBotLib\Objects > Location --- src/TgBotLib/Objects/Location.php | 139 ++++++++++++++++++++++++++++++ 1 file changed, 139 insertions(+) create mode 100644 src/TgBotLib/Objects/Location.php diff --git a/src/TgBotLib/Objects/Location.php b/src/TgBotLib/Objects/Location.php new file mode 100644 index 0000000..a0b0c31 --- /dev/null +++ b/src/TgBotLib/Objects/Location.php @@ -0,0 +1,139 @@ +longitude; + } + + /** + * Latitude as defined by sender + * + * @return float + */ + public function getLatitude(): float + { + return $this->latitude; + } + + /** + * Optional. The radius of uncertainty for the location, measured in meters; 0-1500 + * + * @return float|int|null + */ + public function getHorizontalAccuracy(): float|int|null + { + return $this->horizontal_accuracy; + } + + /** + * Optional. Time relative to the message sending date, during which the location can be updated; in seconds. + * For active live locations only. + * + * @return int|null + */ + public function getLivePeriod(): ?int + { + return $this->live_period; + } + + /** + * Optional. The direction in which user is moving, in degrees; 1-360. For active live locations only. + * + * @return int|null + */ + public function getHeading(): ?int + { + return $this->heading; + } + + /** + * Optional. The maximum distance for proximity alerts about approaching another chat member, in meters. + * For sent live locations only. + * + * @return int|null + */ + public function getProximityAlertRadius(): ?int + { + return $this->proximity_alert_radius; + } + + /** + * Returns an array representation of the object. + * + * @return array + */ + public function toArray(): array + { + return [ + 'longitude' => $this->longitude, + 'latitude' => $this->latitude, + 'horizontal_accuracy' => $this->horizontal_accuracy, + 'live_period' => $this->live_period, + 'heading' => $this->heading, + 'proximity_alert_radius' => $this->proximity_alert_radius + ]; + } + + /** + * Constructs an object from an array representation. + * + * @param array $data + * @return ObjectTypeInterface + */ + public static function fromArray(array $data): ObjectTypeInterface + { + $object = new self(); + + $object->longitude = $data['longitude']; + $object->latitude = $data['latitude']; + $object->horizontal_accuracy = $data['horizontal_accuracy']; + $object->live_period = $data['live_period']; + $object->heading = $data['heading']; + $object->proximity_alert_radius = $data['proximity_alert_radius']; + + return $object; + } + } \ No newline at end of file