Added \TgBotLib\Objects\ChatMember > ChatMemberLeft
This commit is contained in:
parent
dc415dc49c
commit
b74c0c2975
1 changed files with 81 additions and 0 deletions
81
src/TgBotLib/Objects/ChatMember/ChatMemberLeft.php
Normal file
81
src/TgBotLib/Objects/ChatMember/ChatMemberLeft.php
Normal file
|
@ -0,0 +1,81 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Objects\ChatMember;
|
||||
|
||||
use TgBotLib\Interfaces\ObjectTypeInterface;
|
||||
use TgBotLib\Objects\ChatMember;
|
||||
use TgBotLib\Objects\User;
|
||||
|
||||
class ChatMemberLeft implements ObjectTypeInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $status;
|
||||
|
||||
/**
|
||||
* @var User
|
||||
*/
|
||||
private $user;
|
||||
|
||||
/**
|
||||
* The member's status in the chat, always “left”
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getStatus(): string
|
||||
{
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Information about the user
|
||||
*
|
||||
* @return User
|
||||
*/
|
||||
public function getUser(): User
|
||||
{
|
||||
return $this->user;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs the 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 = User::fromArray($data['user']);
|
||||
return $object;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs the object from ChatMember object
|
||||
*
|
||||
* @param ChatMember $chatMember
|
||||
* @return static
|
||||
*/
|
||||
public static function fromChatMember(ChatMember $chatMember): self
|
||||
{
|
||||
$object = new self();
|
||||
$object->status = $chatMember->getStatus();
|
||||
$object->user = $chatMember->getUser();
|
||||
return $object;
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue