Bundle to format phone numbers in E164 format
$formatter = $this->container->get('guru_phone_number_formatter.formatter');
// optional: set current country - if known
$formatter->setDefaultRegionCode('my');
$e164 = $formatter->numberToE164('0101234567', '60');
$e164 = $formatter->numberToE164('+60101234567');
$e164 = $formatter->numberToE164('+60101234567', '60');
/*
Output:
array(
'countryCode' => '60',
'nationalDestinationCode' => '010',
'nationalDestinationCodeInternational' => '10',
'subscriberNumber' => '1234567',
'isMobile' => true,
)
*/
$e164 = $formatter->numberToE164('+65101234567', '60');
/*
Output:
array(
'countryCode' => '65',
'nationalDestinationCode' => NULL,
'nationalDestinationCodeInternational' => NULL,
'subscriberNumber' => '101234567',
'isMobile' => false,
)
*/