/**
  * 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'));
 }
 public function formatByDigitCount(PhoneNumber $E164)
 {
     if ($E164->getSubscriberNumber() === '' || $E164->getSubscriberNumber() === null) {
         return null;
     }
     $numberString = '';
     //add country code
     if ($E164->getCountryCode() !== '' && $E164->getCountryCode() !== null) {
         $numberString .= '+' . $E164->getCountryCode();
     }
     //add region / mobile code
     if ($E164->getNationalDestinationCode() != '') {
         //see if we need local / international code
         $code = '';
         if ($E164->getCountryCode() !== '' && $E164->getCountryCode() !== null) {
             $code = $E164->getNationalDestinationCodeInternational();
         } else {
             $code = $E164->getNationalDestinationCode();
         }
         $numberString .= ($numberString != '' ? ' ' : '') . $code;
     }
     $numberString .= ($numberString != '' ? ' ' : '') . $this->formatNumberByDigits($E164->getSubscriberNumber(), $E164->getCountryCode());
     return $numberString;
 }