2023-02-12 17:12:56 -05:00
|
|
|
<?php
|
|
|
|
|
2024-10-02 00:18:12 -04:00
|
|
|
namespace TgBotLib\Objects;
|
2023-02-12 17:12:56 -05:00
|
|
|
|
|
|
|
use TgBotLib\Interfaces\ObjectTypeInterface;
|
|
|
|
|
|
|
|
class VideoNote implements ObjectTypeInterface
|
|
|
|
{
|
2024-10-06 16:06:23 -04:00
|
|
|
private string $file_id;
|
|
|
|
private string $file_unique_id;
|
|
|
|
private int $length;
|
|
|
|
private int $duration;
|
|
|
|
private ?PhotoSize $thumbnail;
|
|
|
|
private ?int $file_size;
|
2023-02-12 17:12:56 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Identifier for this file, which can be used to download or reuse the file
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getFileId(): string
|
|
|
|
{
|
|
|
|
return $this->file_id;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Unique identifier for this file, which is supposed to be the same over time
|
|
|
|
* and for different bots. Can't be used to download or reuse the file.
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getFileUniqueId(): string
|
|
|
|
{
|
|
|
|
return $this->file_unique_id;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Video width and height (diameter of the video message) as defined by sender
|
|
|
|
*
|
|
|
|
* @return int
|
|
|
|
*/
|
|
|
|
public function getLength(): int
|
|
|
|
{
|
|
|
|
return $this->length;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Duration of the video in seconds as defined by sender
|
|
|
|
*
|
|
|
|
* @return int
|
|
|
|
*/
|
|
|
|
public function getDuration(): int
|
|
|
|
{
|
|
|
|
return $this->duration;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Optional. Video thumbnail
|
|
|
|
*
|
|
|
|
* @return PhotoSize|null
|
|
|
|
*/
|
2023-04-10 19:21:05 -04:00
|
|
|
public function getThumbnail(): ?PhotoSize
|
2023-02-12 17:12:56 -05:00
|
|
|
{
|
2023-04-10 19:21:05 -04:00
|
|
|
return $this->thumbnail;
|
2023-02-12 17:12:56 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Optional. File size in bytes
|
|
|
|
*
|
|
|
|
* @return int|null
|
|
|
|
*/
|
|
|
|
public function getFileSize(): ?int
|
|
|
|
{
|
|
|
|
return $this->file_size;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2024-10-06 16:06:23 -04:00
|
|
|
* @inheritDoc
|
2023-02-12 17:12:56 -05:00
|
|
|
*/
|
|
|
|
public function toArray(): array
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
'file_id' => $this->file_id,
|
|
|
|
'file_unique_id' => $this->file_unique_id,
|
|
|
|
'length' => $this->length,
|
|
|
|
'duration' => $this->duration,
|
2024-10-06 16:06:23 -04:00
|
|
|
'thumbnail' => $this->thumbnail?->toArray(),
|
2023-02-12 17:12:56 -05:00
|
|
|
'file_size' => $this->file_size,
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2024-10-06 16:06:23 -04:00
|
|
|
* @inheritDoc
|
2023-02-12 17:12:56 -05:00
|
|
|
*/
|
2024-10-06 16:06:23 -04:00
|
|
|
public static function fromArray(?array $data): ?VideoNote
|
2023-02-12 17:12:56 -05:00
|
|
|
{
|
2024-10-06 16:06:23 -04:00
|
|
|
if($data === null)
|
|
|
|
{
|
|
|
|
return null;
|
|
|
|
}
|
2023-02-12 17:12:56 -05:00
|
|
|
|
2024-10-06 16:06:23 -04:00
|
|
|
$object = new self();
|
2023-02-14 17:35:16 -05:00
|
|
|
$object->file_id = $data['file_id'];
|
|
|
|
$object->file_unique_id = $data['file_unique_id'];
|
|
|
|
$object->length = $data['length'];
|
|
|
|
$object->duration = $data['duration'];
|
2024-10-06 16:06:23 -04:00
|
|
|
$object->thumbnail = isset($data['thumbnail']) ? PhotoSize::fromArray($data['thumbnail']) : null;
|
2023-02-14 17:35:16 -05:00
|
|
|
$object->file_size = $data['file_size'];
|
2023-02-12 17:12:56 -05:00
|
|
|
|
|
|
|
return $object;
|
|
|
|
}
|
|
|
|
}
|