/** * Helper function * Ensure that local prefixes start with 0 and that international prefixes don't start with 0 **/ protected function correctPrefixLeadingZero(PhoneNumber $phoneNumber) { $prefix = $phoneNumber->getNationalDestinationCode(); //make sure that the prefix codes contain the correct number of 0's $phoneNumber->setNationalDestinationCode(strpos($prefix, '0') !== 0 ? '0' . $prefix : $prefix); $phoneNumber->setNationalDestinationCodeInternational(ltrim($prefix, '0')); }
/** * @dataProvider provideFormatByDigitCount **/ public function testFormatByDigitCount($expected, $E164) { $this->initRegionFormatters($this->formatter); $phoneNumber = new PhoneNumber(); $phoneNumber->setCountryCode($E164['countryCode']); $phoneNumber->setSubscriberNumber($E164['subscriberNumber']); $phoneNumber->setNationalDestinationCode($E164['nationalDestinationCode']); $phoneNumber->setNationalDestinationCodeInternational($E164['nationalDestinationCodeInternational']); $actual = $this->formatter->formatByDigitCount($phoneNumber); $this->assertEquals($expected, $actual); }