cleanup code

This commit is contained in:
2022-06-24 16:00:56 +02:00
parent 50cf733101
commit fae19607c2
16 changed files with 213 additions and 649 deletions

View File

@ -5,7 +5,9 @@ declare(strict_types=1);
namespace D3\LinkmobilityClient\ValueObject;
use Assert\Assert;
use libphonenumber\PhoneNumberType;
use libphonenumber\NumberParseException;
use libphonenumber\PhoneNumberFormat;
use libphonenumber\PhoneNumberUtil;
class Recipient extends StringValueObject
{
@ -18,11 +20,11 @@ class Recipient extends StringValueObject
{
Assert::that($iso2CountryCode)->string()->length(2);
$phoneUtil = \libphonenumber\PhoneNumberUtil::getInstance();
$phoneUtil = PhoneNumberUtil::getInstance();
try {
$phoneNumber = $phoneUtil->parse($number, strtoupper($iso2CountryCode));
$number = ltrim($phoneUtil->format($phoneNumber, \libphonenumber\PhoneNumberFormat::E164), '+');
} catch (\libphonenumber\NumberParseException $e) {
$number = ltrim($phoneUtil->format($phoneNumber, PhoneNumberFormat::E164), '+');
} catch ( NumberParseException $e) {
var_dump($e);
}