Added \TgBotLib\Objects > ChatMember > ChatMemberBanned
This commit is contained in:
parent
b74c0c2975
commit
aa7296e988
1 changed files with 103 additions and 0 deletions
103
src/TgBotLib/Objects/ChatMember/ChatMemberBanned.php
Normal file
103
src/TgBotLib/Objects/ChatMember/ChatMemberBanned.php
Normal file
|
@ -0,0 +1,103 @@
|
|||
<?php
|
||||
|
||||
/** @noinspection PhpMissingFieldTypeInspection */
|
||||
|
||||
namespace TgBotLib\Objects\ChatMember;
|
||||
|
||||
use TgBotLib\Interfaces\ObjectTypeInterface;
|
||||
use TgBotLib\Objects\ChatMember;
|
||||
use TgBotLib\Objects\User;
|
||||
|
||||
class ChatMemberBanned implements ObjectTypeInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $status;
|
||||
|
||||
/**
|
||||
* @var User
|
||||
*/
|
||||
private $user;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $until_date;
|
||||
|
||||
/**
|
||||
* The member's status in the chat, always “kicked”
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getStatus(): string
|
||||
{
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Information about the user
|
||||
*
|
||||
* @return User
|
||||
*/
|
||||
public function getUser(): User
|
||||
{
|
||||
return $this->user;
|
||||
}
|
||||
|
||||
/**
|
||||
* Date when restrictions will be lifted for this user; unix time. If 0, then the user is banned forever
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getUntilDate(): int
|
||||
{
|
||||
return $this->until_date;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array representation of the object
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function toArray(): array
|
||||
{
|
||||
return [
|
||||
'status' => $this->status,
|
||||
'user' => ($this->user instanceof ObjectTypeInterface) ? $this->user->toArray() : $this->user,
|
||||
'until_date' => $this->until_date
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs object from an array representation
|
||||
*
|
||||
* @param array $data
|
||||
* @return ObjectTypeInterface
|
||||
*/
|
||||
public static function fromArray(array $data): ObjectTypeInterface
|
||||
{
|
||||
$object = new self();
|
||||
$object->status = $data['status'];
|
||||
$object->user = isset($data['user']) ? User::fromArray($data['user']) : null;
|
||||
$object->until_date = $data['until_date'];
|
||||
|
||||
return $object;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs object from a ChatMember object
|
||||
*
|
||||
* @param ChatMember $chatMember
|
||||
* @return ChatMemberBanned
|
||||
*/
|
||||
public static function fromChatMember(ChatMember $chatMember): ChatMemberBanned
|
||||
{
|
||||
$object = new self();
|
||||
$object->status = $chatMember->getStatus();
|
||||
$object->user = $chatMember->getUser();
|
||||
$object->until_date = $chatMember->getUntilDate();
|
||||
|
||||
return $object;
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue