From a147a5269e9cc95de18a44232aec0de99bda75b7 Mon Sep 17 00:00:00 2001 From: Netkas Date: Sun, 12 Feb 2023 21:58:31 -0500 Subject: [PATCH] Added \TgBotLib\Objects > UserProfilePhotos --- src/TgBotLib/Objects/UserProfilePhotos.php | 75 ++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 src/TgBotLib/Objects/UserProfilePhotos.php diff --git a/src/TgBotLib/Objects/UserProfilePhotos.php b/src/TgBotLib/Objects/UserProfilePhotos.php new file mode 100644 index 0000000..e8304a5 --- /dev/null +++ b/src/TgBotLib/Objects/UserProfilePhotos.php @@ -0,0 +1,75 @@ +total_count; + } + + /** + * Requested profile pictures (in up to 4 sizes each) + * + * @return PhotoSize[][] + */ + public function getPhotos(): array + { + return $this->photos; + } + + /** + * Returns an array representation of the object + * + * @return array + */ + public function toArray(): array + { + return [ + 'total_count' => $this->total_count, + 'photos' => array_map(function (array $photo) { + return array_map(function (PhotoSize $photoSize) { + return $photoSize->toArray(); + }, $photo); + }, $this->photos), + ]; + } + + /** + * Constructs object from an array representation + * + * @param array $data + * @return ObjectTypeInterface + */ + public static function fromArray(array $data): ObjectTypeInterface + { + $object = new self(); + $object->total_count = $data['total_count']; + $object->photos = array_map(function (array $photo) { + return array_map(function (array $photoSize) { + return PhotoSize::fromArray($photoSize); + }, $photo); + }, $data['photos']); + return $object; + } + } \ No newline at end of file