tgbotlib/src/TgBotLib/Objects/ChatLocation.php

55 lines
1.3 KiB
PHP
Raw Normal View History

2023-02-13 20:07:44 -05:00
<?php
2024-10-02 00:18:12 -04:00
namespace TgBotLib\Objects;
2023-02-13 20:07:44 -05:00
use TgBotLib\Interfaces\ObjectTypeInterface;
class ChatLocation implements ObjectTypeInterface
{
2024-10-04 14:56:02 -04:00
private Location $location;
private string $address;
2023-02-13 20:07:44 -05:00
/**
* The location to which the supergroup is connected. Can't be a live location.
*
* @return Location
*/
public function getLocation(): Location
{
return $this->location;
}
/**
* Location address; 1-64 characters, as defined by the chat owner
*
* @return string
*/
public function getAddress(): string
{
return $this->address;
}
/**
2024-10-04 14:56:02 -04:00
* @inheritDoc
2023-02-13 20:07:44 -05:00
*/
public function toArray(): array
{
return [
2024-10-04 14:56:02 -04:00
'location' => $this->location?->toArray(),
2023-02-13 20:07:44 -05:00
'address' => $this->address,
];
}
/**
2024-10-04 14:56:02 -04:00
* @inheritDoc
2023-02-13 20:07:44 -05:00
*/
2024-10-04 14:56:02 -04:00
public static function fromArray(?array $data): ChatLocation
2023-02-13 20:07:44 -05:00
{
$object = new self();
$object->location = isset($data['location']) ? Location::fromArray($data['location']) : null;
2023-02-14 17:35:16 -05:00
$object->address = $data['address'] ?? null;
2023-02-13 20:07:44 -05:00
return $object;
}
}