Updated Venue

This commit is contained in:
netkas 2024-10-06 15:58:00 -04:00
parent fb1be54bb7
commit 38657c128d

View file

@ -6,40 +6,13 @@
class Venue implements ObjectTypeInterface class Venue implements ObjectTypeInterface
{ {
/** private Location $location;
* @var Location private string $title;
*/ private string $address;
private $location; private ?string $foursquare_id;
private ?string $foursquare_type;
/** private ?string $google_place_id;
* @var string private ?string $google_place_type;
*/
private $title;
/**
* @var string
*/
private $address;
/**
* @var string|null
*/
private $foursquare_id;
/**
* @var string|null
*/
private $foursquare_type;
/**
* @var string|null
*/
private $google_place_id;
/**
* @var string|null
*/
private $google_place_type;
/** /**
* Venue location. Can't be a live location * Venue location. Can't be a live location
@ -114,14 +87,12 @@
} }
/** /**
* 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(),
'title' => $this->title, 'title' => $this->title,
'address' => $this->address, 'address' => $this->address,
'foursquare_id' => $this->foursquare_id, 'foursquare_id' => $this->foursquare_id,
@ -132,15 +103,16 @@
} }
/** /**
* Constructs object from an array representation * @inheritDoc
*
* @param array $data
* @return Venue
*/ */
public static function fromArray(array $data): self public static function fromArray(?array $data): ?Venue
{ {
$object = new self(); if($data === null)
{
return null;
}
$object = new self();
$object->location = isset($data['location']) ? Location::fromArray($data['location']) : null; $object->location = isset($data['location']) ? Location::fromArray($data['location']) : null;
$object->title = $data['title']; $object->title = $data['title'];
$object->address = $data['address']; $object->address = $data['address'];