tgbotlib/src/TgBotLib/Objects/ChatShared.php

64 lines
1.7 KiB
PHP
Raw Normal View History

2023-02-12 21:45:31 -05:00
<?php
2024-10-02 00:18:12 -04:00
namespace TgBotLib\Objects;
2023-02-12 21:45:31 -05:00
use TgBotLib\Interfaces\ObjectTypeInterface;
class ChatShared implements ObjectTypeInterface
{
2024-10-04 15:01:33 -04:00
private int $request_id;
private int $chat_id;
2023-02-12 21:45:31 -05:00
/**
* Identifier of the request
*
2023-02-12 21:45:31 -05:00
* @return int
*/
public function getRequestId(): int
{
return $this->request_id;
}
/**
* Identifier of the shared chat. This number may have more than 32 significant bits and some programming
* languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits,
* so a 64-bit integer or double-precision float type are safe for storing this identifier.
* The bot may not have access to the chat and could be unable to use this identifier, unless the chat is
* already known to the bot by some other means.
*
2023-02-12 21:45:31 -05:00
* @return int
*/
public function getChatId(): int
{
return $this->chat_id;
}
/**
2024-10-04 15:01:33 -04:00
* @inheritDoc
2023-02-12 21:45:31 -05:00
*/
public function toArray(): array
{
return [
'request_id' => $this->request_id,
'chat_id' => $this->chat_id,
];
}
/**
2024-10-04 15:01:33 -04:00
* @inheritDoc
2023-02-12 21:45:31 -05:00
*/
2024-10-04 15:01:33 -04:00
public static function fromArray(?array $data): ?ChatShared
2023-02-12 21:45:31 -05:00
{
2024-10-04 15:01:33 -04:00
if($data === null)
{
return null;
}
2023-02-12 21:45:31 -05:00
2024-10-04 15:01:33 -04:00
$object = new self();
2023-02-14 17:35:16 -05:00
$object->request_id = $data['request_id'] ?? null;
$object->chat_id = $data['chat_id'] ?? null;
2023-02-12 21:45:31 -05:00
return $object;
}
}