Updated ProximityAlertTriggered
This commit is contained in:
parent
75fb759100
commit
6f32bba06e
1 changed files with 15 additions and 26 deletions
|
@ -7,20 +7,9 @@
|
||||||
|
|
||||||
class ProximityAlertTriggered implements ObjectTypeInterface
|
class ProximityAlertTriggered implements ObjectTypeInterface
|
||||||
{
|
{
|
||||||
/**
|
private User $traveler;
|
||||||
* @var User
|
private User $watcher;
|
||||||
*/
|
private int $distance;
|
||||||
private $traveler;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var User
|
|
||||||
*/
|
|
||||||
private $watcher;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
private $distance;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* User that triggered the alert
|
* User that triggered the alert
|
||||||
|
@ -53,30 +42,30 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an array representation of the object.
|
* @inheritDoc
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
*/
|
||||||
public function toArray(): array
|
public function toArray(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'traveler' => ($this->traveler instanceof ObjectTypeInterface) ? $this->traveler->toArray() : $this->traveler,
|
'traveler' => $this->traveler?->toArray(),
|
||||||
'watcher' => ($this->watcher instanceof ObjectTypeInterface) ? $this->watcher->toArray() : $this->watcher,
|
'watcher' => $this->watcher?->toArray(),
|
||||||
'distance' => $this->distance,
|
'distance' => $this->distance,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs the object from an array representation.
|
* @inheritDoc
|
||||||
*
|
|
||||||
* @param array $data
|
|
||||||
* @return ProximityAlertTriggered
|
|
||||||
*/
|
*/
|
||||||
public static function fromArray(array $data): self
|
public static function fromArray(?array $data): ?ProximityAlertTriggered
|
||||||
{
|
{
|
||||||
|
if($data === null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
$object = new self();
|
$object = new self();
|
||||||
$object->traveler = isset($data['traveler']) && is_array($data['traveler']) ? User::fromArray($data['traveler']) : $data['traveler'];
|
$object->traveler = isset($data['traveler']) ? User::fromArray($data['traveler']) : $data['traveler'];
|
||||||
$object->watcher = isset($data['watcher']) && is_array($data['watcher']) ? User::fromArray($data['watcher']) : $data['watcher'];
|
$object->watcher = isset($data['watcher']) ? User::fromArray($data['watcher']) : $data['watcher'];
|
||||||
$object->distance = $data['distance'];
|
$object->distance = $data['distance'];
|
||||||
|
|
||||||
return $object;
|
return $object;
|
||||||
|
|
Loading…
Add table
Reference in a new issue