tgbotlib/src/TgBotLib/Objects/InaccessibleMessage.php

61 lines
1.2 KiB
PHP
Raw Normal View History

2024-10-01 12:43:44 -04:00
<?php
2024-10-02 00:18:12 -04:00
namespace TgBotLib\Objects;
2024-10-01 12:43:44 -04:00
use TgBotLib\Interfaces\ObjectTypeInterface;
class InaccessibleMessage extends MaybeInaccessibleMessage implements ObjectTypeInterface
{
private Chat $chat;
private int $message_id;
/**
* Chat the message belonged to
*
* @return Chat
*/
public function getChat(): Chat
{
return $this->chat;
}
/**
* Unique message identifier inside the chat
*
* @return int
*/
public function getMessageId(): int
{
return $this->message_id;
}
/**
* @inheritDoc
*/
public function toArray(): array
{
return [
'chat' => $this->chat->toArray(),
'message_id' => $this->message_id,
'date' => $this->date
];
}
/**
* @inheritDoc
*/
2024-10-04 21:21:30 -04:00
public static function fromArray(?array $data): ?InaccessibleMessage
2024-10-01 12:43:44 -04:00
{
2024-10-04 21:21:30 -04:00
if($data === null)
{
return null;
}
2024-10-01 12:43:44 -04:00
2024-10-04 21:21:30 -04:00
$object = new self();
2024-10-01 12:43:44 -04:00
$object->chat = isset($data['chat']) ? Chat::fromArray($data['chat']) : null;
$object->message_id = $data['message_id'];
$object->date = $data['data'];
return $object;
}
}