format sender address as integer

This commit is contained in:
Daniel Seifert 2022-07-12 10:04:04 +02:00
parent 81236bcf2c
commit 81b20fc979
Signed by: DanielS
GPG Key ID: 8A7C4C6ED1915C6F
3 changed files with 15 additions and 2 deletions

View File

@ -162,7 +162,7 @@ abstract class Request implements RequestInterface
'priority' => $this->getPriority(),
'recipientAddressList' => $this->getRecipientsList()->getRecipients(),
'sendAsFlashSms' => $this->doSendAsFlashSms(),
'senderAddress' => $this->getSenderAddress() ? $this->getSenderAddress()->get() : null,
'senderAddress' => $this->getSenderAddress() ? $this->getSenderAddress()->getFormatted() : null,
'senderAddressType' => $this->getSenderAddressType(),
'test' => $this->getTestMode(),
'validityPeriode' => $this->getValidityPeriode()

View File

@ -27,7 +27,7 @@ class Sender extends StringValueObject
$phoneUtil = $this->getPhoneNumberUtil();
$phoneNumber = $phoneUtil->parse( $number, strtoupper($iso2CountryCode) );
$number = $phoneUtil->format( $phoneNumber, PhoneNumberFormat::E164 );
$number = ltrim($phoneUtil->format($phoneNumber, PhoneNumberFormat::E164), '+');
if (false === $phoneUtil->isValidNumber($phoneNumber)) {
throw new RecipientException( ExceptionMessages::INVALID_SENDER );
@ -43,4 +43,12 @@ class Sender extends StringValueObject
{
return PhoneNumberUtil::getInstance();
}
/**
* @return int
*/
public function getFormatted()
{
return (int) parent::getFormatted();
}
}

View File

@ -24,4 +24,9 @@ abstract class StringValueObject extends ValueObject
{
return $this->value;
}
public function getFormatted()
{
return $this->get();
}
}