func GetLengthOfGeographicalAreaCode()

in phonenumbers.go [903:932]


func GetLengthOfGeographicalAreaCode(number *PhoneNumber) int {
	metadata := getMetadataForRegion(GetRegionCodeForNumber(number))
	if metadata == nil {
		return 0
	}

	numType := GetNumberType(number)
	countryCallingCode := number.GetCountryCode()

	// If a country doesn't use a national prefix, and this number doesn't have an Italian leading
	// zero, we assume it is a closed dialling plan with no area codes.
	// Note:this is our general assumption, but there are exceptions which are tracked in
	// COUNTRIES_WITHOUT_NATIONAL_PREFIX_WITH_AREA_CODES.
	if len(metadata.GetNationalPrefix()) == 0 && !number.GetItalianLeadingZero() && !COUNTRIES_WITHOUT_NATIONAL_PREFIX_WITH_AREA_CODES[countryCallingCode] {
		return 0
	}

	// Note this is a rough heuristic; it doesn't cover Indonesia well, for example, where area
	// codes are present for some mobile phones but not for others. We have no better way of
	// representing this in the metadata at this point.
	if numType == MOBILE && GEO_MOBILE_COUNTRIES_WITHOUT_MOBILE_AREA_CODES[countryCallingCode] {
		return 0
	}

	if !isNumberGeographical(number) {
		return 0
	}

	return GetLengthOfNationalDestinationCode(number)
}