From e12979d7af76e75724c4e4ecef9aa50f3d7dc278 Mon Sep 17 00:00:00 2001 From: netkas Date: Fri, 4 Oct 2024 21:09:36 -0400 Subject: [PATCH] Updated File --- src/TgBotLib/Objects/File.php | 40 ++++++++++++----------------------- 1 file changed, 13 insertions(+), 27 deletions(-) diff --git a/src/TgBotLib/Objects/File.php b/src/TgBotLib/Objects/File.php index a45a8e9..7282c32 100644 --- a/src/TgBotLib/Objects/File.php +++ b/src/TgBotLib/Objects/File.php @@ -7,25 +7,10 @@ class File implements ObjectTypeInterface { - /** - * @var string - */ - private $file_id; - - /** - * @var string - */ - private $file_unique_id; - - /** - * @var int|null - */ - private $file_size; - - /** - * @var string|null - */ - private $file_path; + private string $file_id; + private string $file_unique_id; + private ?int $file_size; + private ?string $file_path; /** * Identifier for this file, which can be used to download or reuse the file @@ -71,9 +56,7 @@ } /** - * Returns an array representation of the object - * - * @return array + * @inheritDoc */ public function toArray(): array { @@ -86,18 +69,21 @@ } /** - * Constructs object from an array representation - * - * @param array $data - * @return File + * @inheritDoc */ - public static function fromArray(array $data): File + public static function fromArray(?array $data): ?File { + if($data === null) + { + return null; + } + $object = new self(); $object->file_id = $data['file_id'] ?? null; $object->file_unique_id = $data['file_unique_id'] ?? null; $object->file_size = $data['file_size'] ?? null; $object->file_path = $data['file_path'] ?? null; + return $object; } } \ No newline at end of file