Added \TgBotLib\Objects > Location
This commit is contained in:
parent
8bfc2e681f
commit
78447603e4
1 changed files with 139 additions and 0 deletions
139
src/TgBotLib/Objects/Location.php
Normal file
139
src/TgBotLib/Objects/Location.php
Normal file
|
@ -0,0 +1,139 @@
|
|||
<?php
|
||||
|
||||
/** @noinspection PhpMissingFieldTypeInspection */
|
||||
|
||||
namespace TgBotLib\Objects;
|
||||
|
||||
use TgBotLib\Interfaces\ObjectTypeInterface;
|
||||
|
||||
class Location implements ObjectTypeInterface
|
||||
{
|
||||
/**
|
||||
* @var float
|
||||
*/
|
||||
private $longitude;
|
||||
|
||||
/**
|
||||
* @var float
|
||||
*/
|
||||
private $latitude;
|
||||
|
||||
/**
|
||||
* @var float|int|null
|
||||
*/
|
||||
private $horizontal_accuracy;
|
||||
|
||||
/**
|
||||
* @var int|null
|
||||
*/
|
||||
private $live_period;
|
||||
|
||||
/**
|
||||
* @var int|null
|
||||
*/
|
||||
private $heading;
|
||||
|
||||
/**
|
||||
* @var int|null
|
||||
*/
|
||||
private $proximity_alert_radius;
|
||||
|
||||
/**
|
||||
* Longitude as defined by sender
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getLongitude(): float
|
||||
{
|
||||
return $this->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;
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue