2024-09-30 13:04:23 -04:00
|
|
|
<?php
|
|
|
|
|
2024-10-02 00:18:12 -04:00
|
|
|
namespace TgBotLib\Objects\MessageOrigin;
|
2024-09-30 13:04:23 -04:00
|
|
|
|
|
|
|
use TgBotLib\Enums\Types\MessageOriginType;
|
|
|
|
use TgBotLib\Interfaces\ObjectTypeInterface;
|
2024-10-02 00:18:12 -04:00
|
|
|
use TgBotLib\Objects\Chat;
|
|
|
|
use TgBotLib\Objects\MessageOrigin;
|
2024-09-30 13:04:23 -04:00
|
|
|
|
|
|
|
class MessageOriginChat extends MessageOrigin implements ObjectTypeInterface
|
|
|
|
{
|
|
|
|
private Chat $sender_chat;
|
|
|
|
private ?string $author_signature;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Unique message identifier inside the chat
|
|
|
|
*
|
|
|
|
* @return Chat
|
|
|
|
*/
|
|
|
|
public function getSenderChat(): Chat
|
|
|
|
{
|
|
|
|
return $this->sender_chat;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Optional. Signature of the original post author
|
|
|
|
*
|
|
|
|
* @return string|null
|
|
|
|
*/
|
|
|
|
public function getAuthorSignature(): ?string
|
|
|
|
{
|
|
|
|
return $this->author_signature;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
*/
|
|
|
|
public function toArray(): array
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
'type' => $this->getType()->value,
|
|
|
|
'date' => $this->getDate(),
|
|
|
|
'sender_chat' => $this->sender_chat->toArray(),
|
|
|
|
'author_signature' => $this->author_signature,
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
*/
|
|
|
|
public static function fromArray(array $data): MessageOrigin
|
|
|
|
{
|
|
|
|
$object = new self();
|
|
|
|
|
|
|
|
$object->type = MessageOriginType::CHAT;
|
|
|
|
$object->date = $data['date'];
|
|
|
|
$object->sender_chat = Chat::fromArray($data['sender_chat']);
|
|
|
|
$object->author_signature = $data['author_signature'] ?? null;
|
|
|
|
|
|
|
|
return $object;
|
|
|
|
}
|
|
|
|
}
|