2023-02-12 21:58:31 -05:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
2024-10-02 00:18:12 -04:00
|
|
|
namespace TgBotLib\Objects;
|
2023-02-12 21:58:31 -05:00
|
|
|
|
|
|
|
use TgBotLib\Interfaces\ObjectTypeInterface;
|
|
|
|
|
|
|
|
class UserProfilePhotos implements ObjectTypeInterface
|
|
|
|
{
|
2024-10-06 15:54:27 -04:00
|
|
|
private int $total_count;
|
|
|
|
private array $photos;
|
2023-02-12 21:58:31 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Total number of profile pictures the target user has
|
|
|
|
*
|
|
|
|
* @return int
|
|
|
|
*/
|
|
|
|
public function getTotalCount(): int
|
|
|
|
{
|
|
|
|
return $this->total_count;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Requested profile pictures (in up to 4 sizes each)
|
|
|
|
*
|
|
|
|
* @return PhotoSize[][]
|
|
|
|
*/
|
|
|
|
public function getPhotos(): array
|
|
|
|
{
|
|
|
|
return $this->photos;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2024-10-06 15:54:27 -04:00
|
|
|
* @inheritDoc
|
2023-02-12 21:58:31 -05:00
|
|
|
*/
|
|
|
|
public function toArray(): array
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
'total_count' => $this->total_count,
|
2023-02-16 15:27:57 -05:00
|
|
|
'photos' => array_map(function (array $photo)
|
|
|
|
{
|
|
|
|
return array_map(function (PhotoSize $photoSize)
|
|
|
|
{
|
2023-02-12 21:58:31 -05:00
|
|
|
return $photoSize->toArray();
|
|
|
|
}, $photo);
|
|
|
|
}, $this->photos),
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2024-10-06 15:54:27 -04:00
|
|
|
* @inheritDoc
|
2023-02-12 21:58:31 -05:00
|
|
|
*/
|
2024-10-06 15:54:27 -04:00
|
|
|
public static function fromArray(?array $data): ?UserProfilePhotos
|
2023-02-12 21:58:31 -05:00
|
|
|
{
|
2024-10-06 15:54:27 -04:00
|
|
|
if($data === null)
|
|
|
|
{
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2023-02-12 21:58:31 -05:00
|
|
|
$object = new self();
|
|
|
|
$object->total_count = $data['total_count'];
|
2023-02-16 15:27:57 -05:00
|
|
|
$object->photos = array_map(function (array $photo)
|
|
|
|
{
|
|
|
|
return array_map(function (array $photoSize)
|
|
|
|
{
|
2023-02-12 21:58:31 -05:00
|
|
|
return PhotoSize::fromArray($photoSize);
|
|
|
|
}, $photo);
|
|
|
|
}, $data['photos']);
|
2024-10-06 15:54:27 -04:00
|
|
|
|
2023-02-12 21:58:31 -05:00
|
|
|
return $object;
|
|
|
|
}
|
|
|
|
}
|