Updated Contact

This commit is contained in:
netkas 2024-10-04 15:02:28 -04:00
parent 746201b395
commit 1aec926fd6

View file

@ -7,30 +7,11 @@
class Contact implements ObjectTypeInterface class Contact implements ObjectTypeInterface
{ {
/** private string $phone_number;
* @var string private string $first_name;
*/ private ?string $last_name;
private $phone_number; private ?int $user_id;
private ?string $vcard;
/**
* @var string
*/
private $first_name;
/**
* @var string|null
*/
private $last_name;
/**
* @var int|null
*/
private $user_id;
/**
* @var string|null
*/
private $vcard;
/** /**
* Contact's phone number * Contact's phone number
@ -85,9 +66,7 @@
} }
/** /**
* Returns an array representation of the object * @inheritDoc
*
* @return array
*/ */
public function toArray(): array public function toArray(): array
{ {
@ -101,15 +80,16 @@
} }
/** /**
* Constructs object from an array representation * @inheritDoc
*
* @param array $data
* @return Contact
*/ */
public static function fromArray(array $data): self public static function fromArray(?array $data): ?Contact
{ {
$object = new self(); if($data === null)
{
return null;
}
$object = new self();
$object->phone_number = $data['phone_number'] ?? null; $object->phone_number = $data['phone_number'] ?? null;
$object->first_name = $data['first_name'] ?? null; $object->first_name = $data['first_name'] ?? null;
$object->last_name = $data['last_name'] ?? null; $object->last_name = $data['last_name'] ?? null;