Updated ChatLocation

This commit is contained in:
netkas 2024-10-04 14:56:02 -04:00
parent 741356c5b5
commit 7b54b8572d

View file

@ -7,15 +7,8 @@
class ChatLocation implements ObjectTypeInterface class ChatLocation implements ObjectTypeInterface
{ {
/** private Location $location;
* @var Location private string $address;
*/
private $location;
/**
* @var string
*/
private $address;
/** /**
* The location to which the supergroup is connected. Can't be a live location. * The location to which the supergroup is connected. Can't be a live location.
@ -38,28 +31,22 @@
} }
/** /**
* Returns an array representation of the object * @inheritDoc
*
* @return array
*/ */
public function toArray(): array public function toArray(): array
{ {
return [ return [
'location' => ($this->location instanceof ObjectTypeInterface) ? $this->location->toArray() : $this->location, 'location' => $this->location?->toArray(),
'address' => $this->address, 'address' => $this->address,
]; ];
} }
/** /**
* Constructs object from an array representation * @inheritDoc
*
* @param array $data
* @return ChatLocation
*/ */
public static function fromArray(array $data): self public static function fromArray(?array $data): ChatLocation
{ {
$object = new self(); $object = new self();
$object->location = isset($data['location']) ? Location::fromArray($data['location']) : null; $object->location = isset($data['location']) ? Location::fromArray($data['location']) : null;
$object->address = $data['address'] ?? null; $object->address = $data['address'] ?? null;