From c92b7a1631dce6f64ceda3077ce19a164b2d5a8a Mon Sep 17 00:00:00 2001 From: James Seconde Date: Mon, 2 Oct 2023 11:30:37 +0100 Subject: [PATCH] make keyword nullable in InboundSMS.php --- src/SMS/Webhook/InboundSMS.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/SMS/Webhook/InboundSMS.php b/src/SMS/Webhook/InboundSMS.php index f0630db3..81c1cfd8 100644 --- a/src/SMS/Webhook/InboundSMS.php +++ b/src/SMS/Webhook/InboundSMS.php @@ -25,7 +25,6 @@ class InboundSMS 'messageId', 'text', 'type', - 'keyword', 'message-timestamp' ]; @@ -60,7 +59,7 @@ class InboundSMS protected $data; /** - * @var string + * @var ?string */ protected $keyword; @@ -126,7 +125,6 @@ public function __construct(array $data) } $this->apiKey = $data['api-key'] ?? null; - $this->keyword = $data['keyword']; $this->messageId = $data['messageId']; $this->messageTimestamp = new DateTimeImmutable($data['message-timestamp']); $this->msisdn = $data['msisdn']; @@ -148,6 +146,10 @@ public function __construct(array $data) $this->udh = $data['udh']; } + if (array_key_exists('keyword', $data)) { + $this->keyword = $data['keyword']; + } + if (array_key_exists('timestamp', $data)) { $this->timestamp = (int)$data['timestamp']; } @@ -183,7 +185,7 @@ public function getData(): ?string return $this->data; } - public function getKeyword(): string + public function getKeyword(): ?string { return $this->keyword; }