From 0a91098f981867e0d81614c5ef08e783ab69de23 Mon Sep 17 00:00:00 2001 From: netkas Date: Sat, 5 Oct 2024 00:34:57 -0400 Subject: [PATCH] Updated PaidMediaInfo --- src/TgBotLib/Objects/PaidMediaInfo.php | 100 +++++++++++++------------ 1 file changed, 52 insertions(+), 48 deletions(-) diff --git a/src/TgBotLib/Objects/PaidMediaInfo.php b/src/TgBotLib/Objects/PaidMediaInfo.php index 653bd01..f3cb566 100644 --- a/src/TgBotLib/Objects/PaidMediaInfo.php +++ b/src/TgBotLib/Objects/PaidMediaInfo.php @@ -1,59 +1,63 @@ star_count; - } + private int $star_count; - /** - * Information about the paid media - * - * @return PaidMedia[] - */ - public function getPaidMedia(): array - { - return $this->paid_media; - } + /** + * @var PaidMedia[] + */ + private array $paid_media; - /** - * @inheritDoc - */ - public function toArray(): array - { - return [ - 'star_count' => $this->star_count, - 'paid_media' => array_map(fn(PaidMedia $paid_media) => $paid_media->toArray(), $this->paid_media), - ]; - } + /** + * The number of Telegram Stars that must be paid to buy access to the media + * + * @return int + */ + public function getStarCount(): int + { + return $this->star_count; + } - /** - * @inheritDoc - */ - public static function fromArray(array $data): PaidMediaInfo - { - $object = new self(); + /** + * Information about the paid media + * + * @return PaidMedia[] + */ + public function getPaidMedia(): array + { + return $this->paid_media; + } - $object->star_count = $data['star_count']; - $object->paid_media = array_map(fn(array $paid_media) => PaidMedia::fromArray($paid_media), $data['paid_media']); + /** + * @inheritDoc + */ + public function toArray(): array + { + return [ + 'star_count' => $this->star_count, + 'paid_media' => array_map(fn(PaidMedia $paid_media) => $paid_media->toArray(), $this->paid_media), + ]; + } - return $object; - } + /** + * @inheritDoc + */ + public static function fromArray(?array $data): ?PaidMediaInfo + { + if($data === null) + { + return null; + } + + $object = new self(); + $object->star_count = $data['star_count']; + $object->paid_media = array_map(fn(array $paid_media) => PaidMedia::fromArray($paid_media), $data['paid_media']); + + return $object; + } } \ No newline at end of file