From aa88f09e166773423edd0390103f34f6baaddeb1 Mon Sep 17 00:00:00 2001 From: Daniel Seifert Date: Thu, 14 Jul 2022 12:05:06 +0200 Subject: [PATCH] move exception message to constant in messages class --- src/Exceptions/ExceptionMessages.php | 2 ++ src/Request/Request.php | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Exceptions/ExceptionMessages.php b/src/Exceptions/ExceptionMessages.php index 99ae8f9..abae814 100644 --- a/src/Exceptions/ExceptionMessages.php +++ b/src/Exceptions/ExceptionMessages.php @@ -25,5 +25,7 @@ class ExceptionMessages public const NOT_A_MOBILE_NUMBER = 'not a mobile number'; + public const EMPTY_RECIPIENT_LIST = 'request must contain a valid recipient'; + public const DEBUG_NOSENDERORCOUNTRYCODE= 'no sender number or sender country code defined, use fallback to account default'; } diff --git a/src/Request/Request.php b/src/Request/Request.php index 3483bfe..5278007 100644 --- a/src/Request/Request.php +++ b/src/Request/Request.php @@ -17,6 +17,7 @@ namespace D3\LinkmobilityClient\Request; use Assert\Assert; use D3\LinkmobilityClient\Client; +use D3\LinkmobilityClient\Exceptions\ExceptionMessages; use D3\LinkmobilityClient\RecipientsList\RecipientsList; use D3\LinkmobilityClient\RecipientsList\RecipientsListInterface; use D3\LinkmobilityClient\Response\ResponseInterface; @@ -140,7 +141,7 @@ abstract class Request implements RequestInterface Assert::that($this->getOptions())->isArray(); Assert::that($this->getRecipientsList())->isInstanceOf(RecipientsList::class)->notEmpty(); - Assert::that($this->getRecipientsList()->getRecipients())->notEmpty('request must contain a valid recipient'); + Assert::that($this->getRecipientsList()->getRecipients())->notEmpty(ExceptionMessages::EMPTY_RECIPIENT_LIST); Assert::thatAll($this->getRecipientsList())->isInstanceOf(Recipient::class)->notEmpty(); // optional properties