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