From 1aec926fd668838459ac24f1bb21e4ebd0627ec8 Mon Sep 17 00:00:00 2001 From: netkas Date: Fri, 4 Oct 2024 15:02:28 -0400 Subject: [PATCH] Updated Contact --- src/TgBotLib/Objects/Contact.php | 46 +++++++++----------------------- 1 file changed, 13 insertions(+), 33 deletions(-) diff --git a/src/TgBotLib/Objects/Contact.php b/src/TgBotLib/Objects/Contact.php index 608dbf1..cb0c976 100644 --- a/src/TgBotLib/Objects/Contact.php +++ b/src/TgBotLib/Objects/Contact.php @@ -7,30 +7,11 @@ class Contact implements ObjectTypeInterface { - /** - * @var string - */ - private $phone_number; - - /** - * @var string - */ - private $first_name; - - /** - * @var string|null - */ - private $last_name; - - /** - * @var int|null - */ - private $user_id; - - /** - * @var string|null - */ - private $vcard; + private string $phone_number; + private string $first_name; + private ?string $last_name; + private ?int $user_id; + private ?string $vcard; /** * Contact's phone number @@ -85,9 +66,7 @@ } /** - * Returns an array representation of the object - * - * @return array + * @inheritDoc */ public function toArray(): array { @@ -101,15 +80,16 @@ } /** - * Constructs object from an array representation - * - * @param array $data - * @return Contact + * @inheritDoc */ - 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->first_name = $data['first_name'] ?? null; $object->last_name = $data['last_name'] ?? null;