From 7738851797946b7f584616c29a99d484476c232c Mon Sep 17 00:00:00 2001 From: netkas Date: Sun, 6 Oct 2024 16:07:59 -0400 Subject: [PATCH] Updated WebAppInfo --- src/TgBotLib/Objects/WebAppInfo.php | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/TgBotLib/Objects/WebAppInfo.php b/src/TgBotLib/Objects/WebAppInfo.php index 6ef7051..585733d 100644 --- a/src/TgBotLib/Objects/WebAppInfo.php +++ b/src/TgBotLib/Objects/WebAppInfo.php @@ -11,7 +11,7 @@ /** * @var string */ - private $url; + private string $url; /** * An HTTPS URL of a Web App to be opened with additional data as specified in Initializing Web Apps @@ -33,16 +33,16 @@ public function setUrl(string $url): self { if(!Validate::url($url)) + { throw new InvalidArgumentException('Invalid url format'); + } $this->url = $url; return $this; } /** - * Returns an array representation of the object. - * - * @return array + * @inheritDoc */ public function toArray(): array { @@ -52,15 +52,18 @@ } /** - * Constructs the object from an array representation. - * - * @param array $data - * @return WebAppInfo + * @inheritDoc */ - public static function fromArray(array $data): self + public static function fromArray(?array $data): ?WebAppInfo { + if($data === null) + { + return null; + } + $object = new self(); $object->url = $data['url']; + return $object; } } \ No newline at end of file