mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
fixup PhoneNumberHelper
This commit is contained in:
parent
d780d95157
commit
68a64aa67f
@ -15,6 +15,7 @@ use GuzzleHttp\Client;
|
|||||||
use GuzzleHttp\Exception\ClientException;
|
use GuzzleHttp\Exception\ClientException;
|
||||||
use GuzzleHttp\Exception\ConnectException;
|
use GuzzleHttp\Exception\ConnectException;
|
||||||
use GuzzleHttp\Exception\ServerException;
|
use GuzzleHttp\Exception\ServerException;
|
||||||
|
use libphonenumber\NumberParseException;
|
||||||
use libphonenumber\PhoneNumber;
|
use libphonenumber\PhoneNumber;
|
||||||
use libphonenumber\PhoneNumberFormat;
|
use libphonenumber\PhoneNumberFormat;
|
||||||
use libphonenumber\PhoneNumberUtil;
|
use libphonenumber\PhoneNumberUtil;
|
||||||
@ -71,14 +72,28 @@ final class PhonenumberHelper implements PhoneNumberHelperInterface
|
|||||||
public function denormalize(string $phoneNumber): string
|
public function denormalize(string $phoneNumber): string
|
||||||
{
|
{
|
||||||
$phoneUtil = PhoneNumberUtil::getInstance();
|
$phoneUtil = PhoneNumberUtil::getInstance();
|
||||||
$phoneNumber = $phoneUtil->parse($phoneNumber);
|
|
||||||
|
|
||||||
return $phoneUtil->format($phoneNumber, PhoneNumberFormat::NATIONAL);
|
return $phoneUtil
|
||||||
|
->format(
|
||||||
|
$phoneUtil->parse($phoneNumber),
|
||||||
|
PhoneNumberFormat::E164
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function format(string $phonenumber): string
|
/**
|
||||||
|
* @param string $phoneNumber A national phone number starting with +
|
||||||
|
* @return string
|
||||||
|
* @throws NumberParseException
|
||||||
|
*/
|
||||||
|
public function format(string $phoneNumber): string
|
||||||
{
|
{
|
||||||
return $this->normalize($phonenumber);
|
$phoneUtil = PhoneNumberUtil::getInstance();
|
||||||
|
|
||||||
|
return $phoneUtil
|
||||||
|
->format(
|
||||||
|
$phoneUtil->parse($phoneNumber, $this->config['default_carrier_code']),
|
||||||
|
PhoneNumberFormat::NATIONAL
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -162,9 +177,12 @@ final class PhonenumberHelper implements PhoneNumberHelperInterface
|
|||||||
public function normalize(string $phoneNumber): string
|
public function normalize(string $phoneNumber): string
|
||||||
{
|
{
|
||||||
$phoneUtil = PhoneNumberUtil::getInstance();
|
$phoneUtil = PhoneNumberUtil::getInstance();
|
||||||
$phoneNumber = $phoneUtil->parse($phoneNumber, $this->config['default_carrier_code']);
|
|
||||||
|
|
||||||
return $phoneUtil->formatNationalNumberWithPreferredCarrierCode($phoneNumber, $this->config['default_carrier_code']);
|
return $phoneUtil
|
||||||
|
->format(
|
||||||
|
$phoneUtil->parse($phoneNumber, $this->config['default_carrier_code']),
|
||||||
|
PhoneNumberFormat::E164
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function performTwilioFormat($phonenumber)
|
private function performTwilioFormat($phonenumber)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user