Added ChatBackground

This commit is contained in:
netkas 2024-10-01 12:41:46 -04:00
parent c2ba0bf68e
commit 088eac6b88

View 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;
}
}