Exemplo n.º 1
0
 /**
  * Returns true when one national number is the suffix of the other or both are the same.
  * @param PhoneNumber $firstNumber
  * @param PhoneNumber $secondNumber
  * @return bool
  */
 private function isNationalNumberSuffixOfTheOther(PhoneNumber $firstNumber, PhoneNumber $secondNumber)
 {
     $firstNumberNationalNumber = trim((string) $firstNumber->getNationalNumber());
     $secondNumberNationalNumber = trim((string) $secondNumber->getNationalNumber());
     return $this->stringEndsWithString($firstNumberNationalNumber, $secondNumberNationalNumber) || $this->stringEndsWithString($secondNumberNationalNumber, $firstNumberNationalNumber);
 }
 /**
  * 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;
 }