Added UserChatBoosts
This commit is contained in:
parent
f17915bab6
commit
22f28c5711
1 changed files with 49 additions and 0 deletions
49
src/TgBotLib/Objects/UserChatBoosts.php
Normal file
49
src/TgBotLib/Objects/UserChatBoosts.php
Normal file
|
@ -0,0 +1,49 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Objects;
|
||||
|
||||
use TgBotLib\Interfaces\ObjectTypeInterface;
|
||||
|
||||
class UserChatBoosts implements ObjectTypeInterface
|
||||
{
|
||||
/**
|
||||
* @var ChatBoost[]
|
||||
*/
|
||||
private array $boosts;
|
||||
|
||||
/**
|
||||
* The list of boosts added to the chat by the user
|
||||
*
|
||||
* @return ChatBoost[]
|
||||
*/
|
||||
public function getBoosts(): array
|
||||
{
|
||||
return $this->boosts;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function toArray(): ?array
|
||||
{
|
||||
return [
|
||||
'boosts' => array_map(fn(ChatBoost $item) => $item->toArray(), $this->boosts)
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function fromArray(?array $data): ?UserChatBoosts
|
||||
{
|
||||
if($data === null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
$object = new self();
|
||||
$object->boosts = array_map(fn(array $item) => ChatBoost::fromArray($item), $data['boosts']);
|
||||
|
||||
return $object;
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue