From efb676b63959067414db483da1fa2399da9819dd Mon Sep 17 00:00:00 2001 From: Netkas Date: Sun, 12 Feb 2023 17:15:37 -0500 Subject: [PATCH] Added \TgBotLib\Objects > Voice --- src/TgBotLib/Objects/Voice.php | 122 +++++++++++++++++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 src/TgBotLib/Objects/Voice.php diff --git a/src/TgBotLib/Objects/Voice.php b/src/TgBotLib/Objects/Voice.php new file mode 100644 index 0000000..e17dd7f --- /dev/null +++ b/src/TgBotLib/Objects/Voice.php @@ -0,0 +1,122 @@ +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; + } + + /** + * Duration of the audio in seconds as defined by sender + * + * @return int + */ + public function getDuration(): int + { + return $this->duration; + } + + /** + * Optional. MIME type of the file as defined by sender + * + * @return string|null + */ + public function getMimeType(): ?string + { + return $this->mime_type; + } + + /** + * Optional. File size in bytes. It can be bigger than 2^31 and some programming languages may have + * difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this value. + * + * @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, + 'duration' => $this->duration, + 'mime_type' => $this->mime_type, + 'file_size' => $this->file_size, + ]; + } + + /** + * Constructs 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->duration = @$data['duration']; + $object->mime_type = @$data['mime_type'] ?? null; + $object->file_size = @$data['file_size'] ?? null; + + return $object; + } + } \ No newline at end of file