Updated PollOption

This commit is contained in:
netkas 2024-10-05 00:49:53 -04:00
parent dba35af7f6
commit 75fb759100

View file

@ -7,15 +7,8 @@
class PollOption implements ObjectTypeInterface class PollOption implements ObjectTypeInterface
{ {
/** private string $text;
* @var string private int $voter_count;
*/
private $text;
/**
* @var int
*/
private $voter_count;
/** /**
* Option text, 1-100 characters * Option text, 1-100 characters
@ -38,9 +31,7 @@
} }
/** /**
* Returns an array representation of the object * @inheritDoc
*
* @return array
*/ */
public function toArray(): array public function toArray(): array
{ {
@ -51,15 +42,16 @@
} }
/** /**
* Constructs an object from an array representation * @inheritDoc
*
* @param array $data
* @return PollOption
*/ */
public static function fromArray(array $data): self public static function fromArray(?array $data): ?PollOption
{ {
$object = new self(); if($data === null)
{
return null;
}
$object = new self();
$object->text = $data['text'] ?? null; $object->text = $data['text'] ?? null;
$object->voter_count = $data['voter_count'] ?? null; $object->voter_count = $data['voter_count'] ?? null;