Added ChatBackground
This commit is contained in:
parent
c2ba0bf68e
commit
088eac6b88
1 changed files with 46 additions and 0 deletions
46
src/TgBotLib/Objects/Telegram/ChatBackground.php
Normal file
46
src/TgBotLib/Objects/Telegram/ChatBackground.php
Normal file
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Objects\Telegram;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use TgBotLib\Interfaces\ObjectTypeInterface;
|
||||
|
||||
class ChatBackground implements ObjectTypeInterface
|
||||
{
|
||||
private BackgroundType $type;
|
||||
|
||||
/**
|
||||
* Type of the background
|
||||
*
|
||||
* @return BackgroundType
|
||||
*/
|
||||
public function getType(): BackgroundType
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function toArray(): array
|
||||
{
|
||||
return [
|
||||
'type' => $this->type->toArray()
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function fromArray(array $data): ObjectTypeInterface
|
||||
{
|
||||
if (!isset($data['type']))
|
||||
{
|
||||
throw new InvalidArgumentException('ChatBackground expected type');
|
||||
}
|
||||
|
||||
$object = new self();
|
||||
$object->type = BackgroundType::fromArray($data['type']);
|
||||
return $object;
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue