Updated WebAppInfo

This commit is contained in:
netkas 2024-10-06 16:07:59 -04:00
parent a214a7c736
commit 7738851797

View file

@ -11,7 +11,7 @@
/** /**
* @var string * @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 * 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 public function setUrl(string $url): self
{ {
if(!Validate::url($url)) if(!Validate::url($url))
{
throw new InvalidArgumentException('Invalid url format'); throw new InvalidArgumentException('Invalid url format');
}
$this->url = $url; $this->url = $url;
return $this; return $this;
} }
/** /**
* Returns an array representation of the object. * @inheritDoc
*
* @return array
*/ */
public function toArray(): array public function toArray(): array
{ {
@ -52,15 +52,18 @@
} }
/** /**
* Constructs the object from an array representation. * @inheritDoc
*
* @param array $data
* @return WebAppInfo
*/ */
public static function fromArray(array $data): self public static function fromArray(?array $data): ?WebAppInfo
{ {
if($data === null)
{
return null;
}
$object = new self(); $object = new self();
$object->url = $data['url']; $object->url = $data['url'];
return $object; return $object;
} }
} }