Exemplo n.º 1
0
 /**
  * Returns true if a number is from a region whose national significant number couldn't contain a
  * leading zero, but has the italian_leading_zero field set to true.
  * @param PhoneNumber $number
  * @return bool
  */
 private function hasUnexpectedItalianLeadingZero(PhoneNumber $number)
 {
     return $number->isItalianLeadingZero() && !$this->isLeadingZeroPossible($number->getCountryCode());
 }
 /**
  * Gets the national significant number of the a phone number. Note a national significant number
  * doesn't contain a national prefix or any formatting.
  *
  * @param \libphonenumber\PhoneNumber $number the phone number for which the national significant number is needed
  * @return string  the national significant number of the PhoneNumber object passed in
  */
 public function getNationalSignificantNumber(PhoneNumber $number)
 {
     // If a leading zero has been set, we prefix this now. Note this is not a national prefix.
     $nationalNumber = $number->isItalianLeadingZero() ? "0" : "";
     $nationalNumber .= $number->getNationalNumber();
     return $nationalNumber;
 }
 /**
  * Merges the information from another phone number into this phone number.
  *
  * @param PhoneNumber $other The phone number to copy.
  *
  * @return PhoneNumber This PhoneNumber instance, for chaining method calls.
  */
 public function mergeFrom(PhoneNumber $other)
 {
     if ($other->hasCountryCode()) {
         $this->setCountryCode($other->getCountryCode());
     }
     if ($other->hasNationalNumber()) {
         $this->setNationalNumber($other->getNationalNumber());
     }
     if ($other->hasExtension()) {
         $this->setExtension($other->getExtension());
     }
     if ($other->hasItalianLeadingZero()) {
         $this->setItalianLeadingZero($other->isItalianLeadingZero());
     }
     if ($other->hasNumberOfLeadingZeros()) {
         $this->setNumberOfLeadingZeros($other->getNumberOfLeadingZeros());
     }
     if ($other->hasRawInput()) {
         $this->setRawInput($other->getRawInput());
     }
     if ($other->hasCountryCodeSource()) {
         $this->setCountryCodeSource($other->getCountryCodeSource());
     }
     if ($other->hasPreferredDomesticCarrierCode()) {
         $this->setPreferredDomesticCarrierCode($other->getPreferredDomesticCarrierCode());
     }
     return $this;
 }
 /**
  * Gets the national significant number of the a phone number. Note a national significant number
  * doesn't contain a national prefix or any formatting.
  * <p>
  * This is a temporary duplicate of the {@code getNationalSignificantNumber} method from
  * {@code PhoneNumberUtil}. Ultimately a canonical static version should exist in a separate
  * utility class (to prevent {@code ShortNumberInfo} needing to depend on PhoneNumberUtil).
  *
  * @param PhoneNumber $number the phone number for which the national significant number is needed
  * @return string the national significant number of the PhoneNumber object passed in
  */
 private function getNationalSignificantNumber(PhoneNumber $number)
 {
     // If leading zero(s) have been set, we prefix this now. Note this is not a national prefix.
     $nationalNumber = '';
     if ($number->isItalianLeadingZero()) {
         $zeros = str_repeat('0', $number->getNumberOfLeadingZeros());
         $nationalNumber .= $zeros;
     }
     $nationalNumber .= $number->getNationalNumber();
     return $nationalNumber;
 }