From 781da3b95e7bfe545f8470091abde247200422c2 Mon Sep 17 00:00:00 2001 From: Netkas Date: Sun, 12 Feb 2023 17:12:56 -0500 Subject: [PATCH] Added \TgBotLib\Objects > VideoNote --- src/TgBotLib/Objects/VideoNote.php | 136 +++++++++++++++++++++++++++++ 1 file changed, 136 insertions(+) create mode 100644 src/TgBotLib/Objects/VideoNote.php diff --git a/src/TgBotLib/Objects/VideoNote.php b/src/TgBotLib/Objects/VideoNote.php new file mode 100644 index 0000000..1c076c3 --- /dev/null +++ b/src/TgBotLib/Objects/VideoNote.php @@ -0,0 +1,136 @@ +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 + */ + public function getThumb(): ?PhotoSize + { + return $this->thumb; + } + + /** + * Optional. File size in bytes + * + * @return int|null + */ + public function getFileSize(): ?int + { + return $this->file_size; + } + + /** + * Returns an array representation of the object + * + * @return array + */ + public function toArray(): array + { + return [ + 'file_id' => $this->file_id, + 'file_unique_id' => $this->file_unique_id, + 'length' => $this->length, + 'duration' => $this->duration, + 'thumb' => ($this->thumb instanceof PhotoSize) ? $this->thumb->toArray() : null, + 'file_size' => $this->file_size, + ]; + } + + /** + * Constructs the object from an array representation + * + * @param array $data + * @return ObjectTypeInterface + */ + public static function fromArray(array $data): ObjectTypeInterface + { + $object = new self(); + + $object->file_id = @$data['file_id']; + $object->file_unique_id = @$data['file_unique_id']; + $object->length = @$data['length']; + $object->duration = @$data['duration']; + $object->thumb = (isset($data['thumb'])) ? PhotoSize::fromArray($data['thumb']) : null; + $object->file_size = @$data['file_size']; + + return $object; + } + } \ No newline at end of file