From aaacd8851e63e14b3764bdf23acb45602ed22d0a Mon Sep 17 00:00:00 2001 From: netkas Date: Fri, 4 Oct 2024 00:14:47 -0400 Subject: [PATCH] Updated InputMessageContent objects --- .../InputMessageContent/InputContactMessageContent.php | 8 ++++++-- .../InputMessageContent/InputInvoiceMessageContent.php | 8 ++++++-- .../InputMessageContent/InputLocationMessageContent.php | 8 ++++++-- .../InputMessageContent/InputTextMessageContent.php | 8 ++++++-- .../InputMessageContent/InputVenueMessageContent.php | 7 ++++++- 5 files changed, 30 insertions(+), 9 deletions(-) diff --git a/src/TgBotLib/Objects/Inline/InputMessageContent/InputContactMessageContent.php b/src/TgBotLib/Objects/Inline/InputMessageContent/InputContactMessageContent.php index 31ad879..65a3d3f 100644 --- a/src/TgBotLib/Objects/Inline/InputMessageContent/InputContactMessageContent.php +++ b/src/TgBotLib/Objects/Inline/InputMessageContent/InputContactMessageContent.php @@ -159,10 +159,14 @@ /** * @inheritDoc */ - public static function fromArray(array $data): InputContactMessageContent + public static function fromArray(?array $data): ?InputContactMessageContent { - $object = new self(); + if($data === null) + { + return null; + } + $object = new self(); $object->type = InputMessageContentType::CONTACT; $object->phone_number = $data['phone_number'] ?? null; $object->first_name = $data['first_name'] ?? null; diff --git a/src/TgBotLib/Objects/Inline/InputMessageContent/InputInvoiceMessageContent.php b/src/TgBotLib/Objects/Inline/InputMessageContent/InputInvoiceMessageContent.php index 699fc07..7152eca 100644 --- a/src/TgBotLib/Objects/Inline/InputMessageContent/InputInvoiceMessageContent.php +++ b/src/TgBotLib/Objects/Inline/InputMessageContent/InputInvoiceMessageContent.php @@ -609,10 +609,14 @@ /** * @inheritDoc */ - public static function fromArray(array $data): InputInvoiceMessageContent + public static function fromArray(?array $data): ?InputInvoiceMessageContent { - $object = new self(); + if($data === null) + { + return null; + } + $object = new self(); $object->type = InputMessageContentType::INVOICE; $object->title = $data['title'] ?? null; $object->description = $data['description'] ?? null; diff --git a/src/TgBotLib/Objects/Inline/InputMessageContent/InputLocationMessageContent.php b/src/TgBotLib/Objects/Inline/InputMessageContent/InputLocationMessageContent.php index c90b0b0..922d6db 100644 --- a/src/TgBotLib/Objects/Inline/InputMessageContent/InputLocationMessageContent.php +++ b/src/TgBotLib/Objects/Inline/InputMessageContent/InputLocationMessageContent.php @@ -217,10 +217,14 @@ /** * @inheritDoc */ - public static function fromArray(array $data): InputLocationMessageContent + public static function fromArray(?array $data): ?InputLocationMessageContent { - $object = new self(); + if($data === null) + { + return null; + } + $object = new self(); $object->type = InputMessageContentType::LOCATION; $object->latitude = (float)$data['latitude'] ?? null; $object->longitude = (float)$data['longitude'] ?? null; diff --git a/src/TgBotLib/Objects/Inline/InputMessageContent/InputTextMessageContent.php b/src/TgBotLib/Objects/Inline/InputMessageContent/InputTextMessageContent.php index 8de75e1..b70810a 100644 --- a/src/TgBotLib/Objects/Inline/InputMessageContent/InputTextMessageContent.php +++ b/src/TgBotLib/Objects/Inline/InputMessageContent/InputTextMessageContent.php @@ -179,10 +179,14 @@ /** * @inheritDoc */ - public static function fromArray(array $data): InputTextMessageContent + public static function fromArray(?array $data): ?InputTextMessageContent { - $object = new self(); + if($data === null) + { + return null; + } + $object = new self(); $object->type = InputMessageContentType::TEXT; $object->message_text = $data['message_text'] ?? null; $object->parse_mode = $data['parse_mode'] ?? null; diff --git a/src/TgBotLib/Objects/Inline/InputMessageContent/InputVenueMessageContent.php b/src/TgBotLib/Objects/Inline/InputMessageContent/InputVenueMessageContent.php index 7253389..2c3b9f3 100644 --- a/src/TgBotLib/Objects/Inline/InputMessageContent/InputVenueMessageContent.php +++ b/src/TgBotLib/Objects/Inline/InputMessageContent/InputVenueMessageContent.php @@ -227,8 +227,13 @@ /** * @inheritDoc */ - public static function fromArray(array $data): InputVenueMessageContent + public static function fromArray(?array $data): ?InputVenueMessageContent { + if($data === null) + { + return null; + } + $object = new self(); $object->type = InputMessageContentType::VENUE; $object->latitude = (float)$data['latitude'] ?? null;