From 3f0dc14e78fab138f1805b4adfd74044de0d1bda Mon Sep 17 00:00:00 2001 From: Netkas Date: Sun, 12 Feb 2023 16:38:11 -0500 Subject: [PATCH] Added \TgBotLib\Objects > PhotoSize --- src/TgBotLib/Objects/PhotoSize.php | 120 +++++++++++++++++++++++++++++ 1 file changed, 120 insertions(+) create mode 100644 src/TgBotLib/Objects/PhotoSize.php diff --git a/src/TgBotLib/Objects/PhotoSize.php b/src/TgBotLib/Objects/PhotoSize.php new file mode 100644 index 0000000..05a8857 --- /dev/null +++ b/src/TgBotLib/Objects/PhotoSize.php @@ -0,0 +1,120 @@ +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; + } + + /** + * Photo width + * + * @return string + */ + public function getWidth(): string + { + return $this->width; + } + + /** + * Photo height + * + * @return string + */ + public function getHeight(): string + { + return $this->height; + } + + /** + * 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, + 'width' => $this->width, + 'height' => $this->height, + 'file_size' => $this->file_size, + ]; + } + + /** + * Constructs an 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->width = $data['width']; + $object->height = $data['height']; + $object->file_size = $data['file_size'] ?? null; + + return $object; + } + } \ No newline at end of file