Updated Messages

This commit is contained in:
netkas 2024-10-04 21:21:30 -04:00
parent 6280b8c026
commit 4558409da5
3 changed files with 18 additions and 5 deletions

View file

@ -44,10 +44,14 @@ class InaccessibleMessage extends MaybeInaccessibleMessage implements ObjectType
/** /**
* @inheritDoc * @inheritDoc
*/ */
public static function fromArray(array $data): InaccessibleMessage public static function fromArray(?array $data): ?InaccessibleMessage
{ {
$object = new self(); if($data === null)
{
return null;
}
$object = new self();
$object->chat = isset($data['chat']) ? Chat::fromArray($data['chat']) : null; $object->chat = isset($data['chat']) ? Chat::fromArray($data['chat']) : null;
$object->message_id = $data['message_id']; $object->message_id = $data['message_id'];
$object->date = $data['data']; $object->date = $data['data'];

View file

@ -27,8 +27,13 @@ abstract class MaybeInaccessibleMessage implements ObjectTypeInterface
/** /**
* @inheritDoc * @inheritDoc
*/ */
public static function fromArray(array $data): MaybeInaccessibleMessage public static function fromArray(?array $data): ?MaybeInaccessibleMessage
{ {
if($data === null)
{
return null;
}
if(!isset($data['date'])) if(!isset($data['date']))
{ {
throw new InvalidArgumentException('Expected date in message'); throw new InvalidArgumentException('Expected date in message');

View file

@ -1088,10 +1088,14 @@
/** /**
* @inheritDoc * @inheritDoc
*/ */
public static function fromArray(array $data): Message public static function fromArray(?array $data): ?Message
{ {
$object = new self(); if($data === null)
{
return null;
}
$object = new self();
$object->message_id = $data['message_id']; $object->message_id = $data['message_id'];
$object->message_thread_id = $data['message_thread_id'] ?? null; $object->message_thread_id = $data['message_thread_id'] ?? null;
$object->from = isset($data['from']) ? User::fromArray($data['from']) : null; $object->from = isset($data['from']) ? User::fromArray($data['from']) : null;