mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
allow phonumber helper to format null value
This commit is contained in:
parent
e82b2bd10a
commit
5f35a42fe3
@ -22,7 +22,7 @@ use libphonenumber\PhoneNumber;
|
|||||||
*/
|
*/
|
||||||
interface PhoneNumberHelperInterface
|
interface PhoneNumberHelperInterface
|
||||||
{
|
{
|
||||||
public function format(PhoneNumber $phoneNumber): string;
|
public function format(?PhoneNumber $phoneNumber = null): string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get type (mobile, landline, ...) for phone number.
|
* Get type (mobile, landline, ...) for phone number.
|
||||||
|
@ -78,8 +78,12 @@ final class PhonenumberHelper implements PhoneNumberHelperInterface
|
|||||||
*
|
*
|
||||||
* @throws NumberParseException
|
* @throws NumberParseException
|
||||||
*/
|
*/
|
||||||
public function format(PhoneNumber $phoneNumber): string
|
public function format(?PhoneNumber $phoneNumber = null): string
|
||||||
{
|
{
|
||||||
|
if (null === $phoneNumber) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
return $this->phoneNumberUtil
|
return $this->phoneNumberUtil
|
||||||
->formatOutOfCountryCallingNumber($phoneNumber, $this->config['default_carrier_code']);
|
->formatOutOfCountryCallingNumber($phoneNumber, $this->config['default_carrier_code']);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user