Updated PollAnswer

This commit is contained in:
netkas 2024-10-05 00:48:55 -04:00
parent d0b4a7cf5c
commit 5d99aa5e14

View file

@ -7,20 +7,12 @@
class PollAnswer implements ObjectTypeInterface class PollAnswer implements ObjectTypeInterface
{ {
/** private string $poll_id;
* @var string private User $user;
*/
private $poll_id;
/**
* @var User
*/
private $user;
/** /**
* @var int[] * @var int[]
*/ */
private $option_ids; private array $option_ids;
/** /**
* Unique poll identifier * Unique poll identifier
@ -53,9 +45,7 @@
} }
/** /**
* Returns an array representation of the object * @inheritDoc
*
* @return array
*/ */
public function toArray(): array public function toArray(): array
{ {
@ -67,17 +57,18 @@
} }
/** /**
* Constructs an object from an array representation * @inheritDoc
*
* @param array $data
* @return PollAnswer
*/ */
public static function fromArray(array $data): self public static function fromArray(?array $data): ?PollAnswer
{ {
$object = new self(); if($data === null)
{
return null;
}
$object = new self();
$object->poll_id = $data['poll_id'] ?? null; $object->poll_id = $data['poll_id'] ?? null;
$object->user = isset($data['user']) && is_array($data['user']) ? User::fromArray($data['user']) : null; $object->user = isset($data['user']) ? User::fromArray($data['user']) : null;
$object->option_ids = $data['option_ids']; $object->option_ids = $data['option_ids'];
return $object; return $object;