From a214a7c73683cc30dc901e03087135378e5dcab6 Mon Sep 17 00:00:00 2001 From: netkas Date: Sun, 6 Oct 2024 16:07:30 -0400 Subject: [PATCH] Updated WebAppData --- src/TgBotLib/Objects/WebAppData.php | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/src/TgBotLib/Objects/WebAppData.php b/src/TgBotLib/Objects/WebAppData.php index 40d7d30..2d6145a 100644 --- a/src/TgBotLib/Objects/WebAppData.php +++ b/src/TgBotLib/Objects/WebAppData.php @@ -6,15 +6,8 @@ class WebAppData implements ObjectTypeInterface { - /** - * @var string - */ - private $data; - - /** - * @var string - */ - private $button_text; + private string $data; + private string $button_text; /** * The data. Be aware that a bad client can send arbitrary data in this field. @@ -38,9 +31,7 @@ } /** - * Returns an array representation of the object. - * - * @return array + * @inheritDoc */ public function toArray(): array { @@ -51,15 +42,16 @@ } /** - * Constructs the object from an array representation. - * - * @param array $data - * @return WebAppData + * @inheritDoc */ - public static function fromArray(array $data): self + public static function fromArray(?array $data): ?WebAppData { - $object = new self(); + if($data === null) + { + return null; + } + $object = new self(); $object->data = $data['data'] ?: ''; $object->button_text = $data['button_text'] ?: '';