Added BusinessLocation
This commit is contained in:
parent
7bf5939a07
commit
f0982e0c3a
1 changed files with 59 additions and 0 deletions
59
src/TgBotLib/Objects/BusinessLocation.php
Normal file
59
src/TgBotLib/Objects/BusinessLocation.php
Normal file
|
@ -0,0 +1,59 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Objects;
|
||||
|
||||
use TgBotLib\Interfaces\ObjectTypeInterface;
|
||||
|
||||
class BusinessLocation implements ObjectTypeInterface
|
||||
{
|
||||
private string $address;
|
||||
private ?Location $location;
|
||||
|
||||
/**
|
||||
* Address of the business
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAddress(): string
|
||||
{
|
||||
return $this->address;
|
||||
}
|
||||
|
||||
/**
|
||||
* Optional. Location of the business
|
||||
*
|
||||
* @return Location|null
|
||||
*/
|
||||
public function getLocation(): ?Location
|
||||
{
|
||||
return $this->location;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function toArray(): ?array
|
||||
{
|
||||
return [
|
||||
'address' => $this->address,
|
||||
'location' => $this->location?->toArray()
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function fromArray(?array $data): ?BusinessLocation
|
||||
{
|
||||
if($data === null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
$object = new self();
|
||||
$object->address = $data['address'];
|
||||
$object->location = isset($data['location']) ? Location::fromArray($data['location']) : null;
|
||||
|
||||
return $object;
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue