define allowed number types as class property

This commit is contained in:
Daniel Seifert 2022-07-18 14:09:19 +02:00
parent dc0b680776
commit 096ef7ed05
Signed by: DanielS
GPG Key ID: 8A7C4C6ED1915C6F
1 changed files with 10 additions and 5 deletions

View File

@ -25,6 +25,14 @@ use libphonenumber\PhoneNumberUtil;
class Recipient extends StringValueObject
{
/**
* @var array
*/
protected $allowedNumberTypes = [
PhoneNumberType::MOBILE,
PhoneNumberType::FIXED_LINE_OR_MOBILE
];
/**
* @var string
*/
@ -52,10 +60,7 @@ class Recipient extends StringValueObject
} elseif (
false === in_array(
$phoneUtil->getNumberType($phoneNumber),
[
PhoneNumberType::MOBILE,
PhoneNumberType::FIXED_LINE_OR_MOBILE
]
$this->allowedNumberTypes
)
) {
throw new RecipientException( ExceptionMessages::NOT_A_MOBILE_NUMBER);