src/prefixmapper/PrefixFileReader.php
public function getDescriptionForNumber(PhoneNumber $number, $language, $script, $region)
    {
        $phonePrefix = $number->getCountryCode() . PhoneNumberUtil::getInstance()->getNationalSignificantNumber($number);

        $phonePrefixDescriptions = $this->getPhonePrefixDescriptions($phonePrefix, $language, $script, $region);

        $description = ($phonePrefixDescriptions !== null) ? $phonePrefixDescriptions->lookup($number) : null;
        // When a location is not available in the requested language, fall back to English.
        if (($description === null || strlen($description) === 0) && $this->mayFallBackToEnglish($language)) {
            $defaultMap = $this->getPhonePrefixDescriptions($phonePrefix, 'en', '', '');
            if ($defaultMap === null) {
                return '';
            }
            $description = $defaultMap->lookup($number);
        }

        return ($description !== null) ? $description : '';
    }
public function getDescriptionForNumber(PhoneNumber $number, $language, $script, $region)
    {
        $phonePrefix = $number->getCountryCode() . PhoneNumberUtil::getInstance()->getNationalSignificantNumber($number);

        $phonePrefixDescriptions = $this->getPhonePrefixDescriptions($phonePrefix, $language, $script, $region);

        $description = ($phonePrefixDescriptions !== null) ? $phonePrefixDescriptions->lookup($number) : null;
        // When a location is not available in the requested language, fall back to English.
        if (($description === null || strlen($description) === 0) && $this->mayFallBackToEnglish($language)) {
            $defaultMap = $this->getPhonePrefixDescriptions($phonePrefix, 'en', '', '');
            if ($defaultMap === null) {
                return '';
            }
            $description = $defaultMap->lookup($number);
        }

        return ($description !== null) ? $description : '';
    }
public function getDescriptionForNumber ( PhoneNumber $ number , $ language , $ script , $ region ) { $ phonePrefix = $ number -> getCountryCode ( ) . PhoneNumberUtil :: getInstance ( ) -> getNationalSignificantNumber ( $ number ) ; $ phonePrefixDescriptions = $ this -> getPhonePrefixDescriptions ( $ phonePrefix , $ language , $ script , $ region ) ; $ description = ( $ phonePrefixDescriptions !== null ) ? $ phonePrefixDescriptions -> lookup ( $ number ) : null ; // When a location is not available in the requested language, fall back to English. if ( ( $ description === null || strlen ( $ description ) === 0 ) && $ this -> mayFallBackToEnglish ( $ language ) ) { $ defaultMap = $ this -> getPhonePrefixDescriptions ( $ phonePrefix , 'en' , '' , '' ) ; if ( $ defaultMap === null ) { return '' ; } $ description = $ defaultMap -> lookup ( $ number ) ; } return ( $ description !== null ) ? $ description : '' ; }
Returns a text description in the given language for the given phone number.

@param PhoneNumber $number the phone number for which we want to get a text description
@param string $language two or three-letter lowercase ISO language as defined by ISO 639
@param string $script four-letter titlecase (the first letter is uppercase and the rest of the letters
are lowercase) ISO script code as defined in ISO 15924
@param string $region two-letter uppercase ISO country code as defined by ISO 3166-1
@return string a text description for the given language code for the given phone number, or empty
string if the number passed in is invalid or could belong to multiple countries
Returns a text description in the given language for the given phone number .