Updated VideoNote

This commit is contained in:
netkas 2024-10-06 16:06:23 -04:00
parent a04140dc8f
commit 3564e2a29d

View file

@ -6,35 +6,12 @@
class VideoNote implements ObjectTypeInterface class VideoNote implements ObjectTypeInterface
{ {
/** private string $file_id;
* @var string private string $file_unique_id;
*/ private int $length;
private $file_id; private int $duration;
private ?PhotoSize $thumbnail;
/** private ?int $file_size;
* @var string
*/
private $file_unique_id;
/**
* @var int
*/
private $length;
/**
* @var int
*/
private $duration;
/**
* @var PhotoSize|null
*/
private $thumbnail;
/**
* @var int|null
*/
private $file_size;
/** /**
* Identifier for this file, which can be used to download or reuse the file * Identifier for this file, which can be used to download or reuse the file
@ -98,9 +75,7 @@
} }
/** /**
* Returns an array representation of the object * @inheritDoc
*
* @return array
*/ */
public function toArray(): array public function toArray(): array
{ {
@ -109,26 +84,27 @@
'file_unique_id' => $this->file_unique_id, 'file_unique_id' => $this->file_unique_id,
'length' => $this->length, 'length' => $this->length,
'duration' => $this->duration, 'duration' => $this->duration,
'thumbnail' => ($this->thumbnail instanceof ObjectTypeInterface) ? $this->thumbnail->toArray() : $this->thumbnail, 'thumbnail' => $this->thumbnail?->toArray(),
'file_size' => $this->file_size, 'file_size' => $this->file_size,
]; ];
} }
/** /**
* Constructs the object from an array representation * @inheritDoc
*
* @param array $data
* @return VideoNote
*/ */
public static function fromArray(array $data): self public static function fromArray(?array $data): ?VideoNote
{ {
$object = new self(); if($data === null)
{
return null;
}
$object = new self();
$object->file_id = $data['file_id']; $object->file_id = $data['file_id'];
$object->file_unique_id = $data['file_unique_id']; $object->file_unique_id = $data['file_unique_id'];
$object->length = $data['length']; $object->length = $data['length'];
$object->duration = $data['duration']; $object->duration = $data['duration'];
$object->thumbnail = (isset($data['thumbnail'])) ? PhotoSize::fromArray($data['thumbnail']) : null; $object->thumbnail = isset($data['thumbnail']) ? PhotoSize::fromArray($data['thumbnail']) : null;
$object->file_size = $data['file_size']; $object->file_size = $data['file_size'];
return $object; return $object;