### Get Example Phone Number Source: https://github.com/giggsey/libphonenumber-for-php-lite/blob/main/docs/PhoneNumberUtil.md Retrieves an example PhoneNumber object for a given region code. Useful for testing purposes. ```php var_dump($phoneNumberUtil->getExampleNumber('GB')); // (PhoneNumber) Country Code: 44 National Number: 1212345678 ... ``` -------------------------------- ### Get Example Short Number Source: https://github.com/giggsey/libphonenumber-for-php-lite/blob/main/docs/ShortNumberInfo.md Fetches an example short phone number for a given region code. This is useful for testing or demonstrating short number formats. ```php var_dump($shortNumberUtil->getExampleShortNumber('GB')); // string(3) "150" ``` -------------------------------- ### Get Example Phone Number for Type Source: https://github.com/giggsey/libphonenumber-for-php-lite/blob/main/docs/PhoneNumberUtil.md Retrieves an example PhoneNumber object for a given region code and PhoneNumberType. If only the type is provided, it returns a valid number of that type from any country. ```php var_dump($phoneNumberUtil->getExampleNumberForType('GB', \libphonenumber\PhoneNumberType::MOBILE)); // (PhoneNumber) Country Code: 44 National Number: 7400123456 ... var_dump($phoneNumberUtil->getExampleNumberForType(\libphonenumber\PhoneNumberType::MOBILE)); // (PhoneNumber) Country Code: 1 National Number: 2015555555 ... ``` -------------------------------- ### Get Instance of ShortNumberInfo Source: https://github.com/giggsey/libphonenumber-for-php-lite/blob/main/docs/ShortNumberInfo.md Retrieves the singleton instance of the ShortNumberInfo class. This is the starting point for using any of its functionalities. ```php $shortNumberUtil = \libphonenumber\ShortNumberInfo::getInstance(); ``` -------------------------------- ### Install libphonenumber-for-php-lite Source: https://github.com/giggsey/libphonenumber-for-php-lite/blob/main/README.md Installs the libphonenumber-for-php-lite library using Composer. This is the recommended installation method and requires Composer to be installed. ```bash $ composer require giggsey/libphonenumber-for-php-lite ``` -------------------------------- ### Get Invalid Example Phone Number Source: https://github.com/giggsey/libphonenumber-for-php-lite/blob/main/docs/PhoneNumberUtil.md Retrieves an example invalid PhoneNumber object for a given region code. This is useful for unit testing with numbers that can be parsed but are not valid or may be short numbers. ```php var_dump($phoneNumberUtil->getInvalidExampleNumber('GB')); // (PhoneNumber) Country Code: 44 National Number: 121234567 ... ``` -------------------------------- ### PhoneNumberUtil Functionality Source: https://github.com/giggsey/libphonenumber-for-php-lite/blob/main/README.md Demonstrates core functionalities of the PhoneNumberUtil class, including parsing, formatting, validation, and retrieving example numbers. It highlights the ability to get the number type and check for matches between numbers. ```php parse('202-456-7890', 'US'); // Formatting a number $formattedNumber = $phoneUtil->format($phoneNumberProto, PhoneNumberUtil::INTERNATIONAL); // Validating a number $isValid = $phoneUtil->isValidNumber($phoneNumberProto); // Getting number type $numberType = $phoneUtil->getNumberType($phoneNumberProto); // Getting an example number $exampleNumber = $phoneUtil->getExampleNumber($countryCode); // Checking if numbers match $isMatch = $phoneUtil->isNumberMatch($phoneNumberProto1, $phoneNumberProto2); ?> ``` -------------------------------- ### Get Geocoder Instance Source: https://github.com/giggsey/libphonenumber-for-php-lite/blob/main/docs/PhoneNumberOfflineGeocoder.md Retrieves the singleton instance of the PhoneNumberOfflineGeocoder. This is the starting point for using the geocoder functionality. ```php $geoCoder = \libphonenumber\geocoding\PhoneNumberOfflineGeocoder::getInstance(); ``` -------------------------------- ### Get PhoneNumberToTimeZonesMapper Instance Source: https://github.com/giggsey/libphonenumber-for-php-lite/blob/main/docs/PhoneNumberToTimeZonesMapper.md Retrieves the singleton instance of the PhoneNumberToTimeZonesMapper class. This is the starting point for using the mapper. ```php $timezoneMapper = \libphonenumber\PhoneNumberToTimeZonesMapper::getInstance(); ``` -------------------------------- ### Get Example Short Number for Cost Source: https://github.com/giggsey/libphonenumber-for-php-lite/blob/main/docs/ShortNumberInfo.md Retrieves a valid short number for a specified region code and cost category (e.g., TOLL_FREE, PREMIUM_RATE). Returns an empty string if no number matches the criteria. ```php var_dump($shortNumberUtil->getExampleShortNumberForCost('GB', \libphonenumber\ShortNumberCost::TOLL_FREE)); // string(6) "116000" var_dump($shortNumberUtil->getExampleShortNumberForCost('GB', \libphonenumber\ShortNumberCost::PREMIUM_RATE)); // string(0) "" var_dump($shortNumberUtil->getExampleShortNumberForCost('US', \libphonenumber\ShortNumberCost::PREMIUM_RATE)); // string(5) "24280" ``` -------------------------------- ### Get PhoneNumberToCarrierMapper Instance Source: https://github.com/giggsey/libphonenumber-for-php-lite/blob/main/docs/PhoneNumberToCarrierMapper.md Demonstrates how to obtain the singleton instance of the PhoneNumberToCarrierMapper class. ```php $carrierMapper = \libphonenumber\PhoneNumberToCarrierMapper::getInstance(); ``` -------------------------------- ### Get Description for Number Source: https://github.com/giggsey/libphonenumber-for-php-lite/blob/main/docs/PhoneNumberOfflineGeocoder.md Provides a text description for a given PhoneNumber object in a specified locale. Optionally, a user region can be provided to influence the description if the number belongs to that region. Examples demonstrate various locales and user regions. ```php $gbNumber = \libphonenumber\PhoneNumberUtil::getInstance()->parse('0161 496 0123', 'GB'); var_dump($geoCoder->getDescriptionForNumber($gbNumber, 'en')); // string(10) "Manchester" var_dump($geoCoder->getDescriptionForNumber($gbNumber, 'en_GB', 'GB')); // string(10) "Manchester" var_dump($geoCoder->getDescriptionForNumber($gbNumber, 'en_GB', 'US')); // string(14) "United Kingdom" var_dump($geoCoder->getDescriptionForNumber($gbNumber, 'ko-KR', 'US')); // string(6) "영국" (Korean for United Kingdom) $usNumber = \libphonenumber\PhoneNumberUtil::getInstance()->parse("+1 650 253 0000", "US"); var_dump($geoCoder->getDescriptionForNumber($usNumber, 'en')); // string(10) "Mountain View, CA" var_dump($geoCoder->getDescriptionForNumber($usNumber, 'en_GB', 'GB')); // string(10) "United States" var_dump($geoCoder->getDescriptionForNumber($usNumber, 'en_GB', 'US')); // string(14) "Mountain View, CA" var_dump($geoCoder->getDescriptionForNumber($usNumber, 'ko-KR', 'US')); // string(6) "미국" (Korean for United States) ``` -------------------------------- ### Get Reason for Number Possibility Source: https://github.com/giggsey/libphonenumber-for-php-lite/blob/main/docs/PhoneNumberUtil.md Returns a ValidationResult constant indicating why a PhoneNumber object is considered possible or not. ```php var_dump($phoneNumberUtil->isPossibleNumberWithReason($phoneNumberObject)); // int(0) (\libphonenumber\ValidationResult::IS_POSSIBLE) ``` -------------------------------- ### Get Region Codes for Country Code Source: https://github.com/giggsey/libphonenumber-for-php-lite/blob/main/docs/PhoneNumberUtil.md Retrieves a list of region codes that correspond to a specified country calling code. For non-geographical codes, it returns '001'. ```php var_dump($phoneNumberUtil->getRegionCodesForCountryCode(44); // array('GB') ``` -------------------------------- ### Get Description for Valid Number Source: https://github.com/giggsey/libphonenumber-for-php-lite/blob/main/docs/PhoneNumberOfflineGeocoder.md This method is functionally identical to `getDescriptionForNumber()`. It is intended for cases where the validity of the phone number for geolocation has already been confirmed. ```php // Returns the same as getDescriptionForNumber(), but assumes that you have already checked whether the number is suitable for geolocation. ``` -------------------------------- ### Get Expected Cost for Region Source: https://github.com/giggsey/libphonenumber-for-php-lite/blob/main/docs/ShortNumberInfo.md Retrieves the expected cost of a phone number for a given region. This method accepts either a PhoneNumber object or a string representation of the number. The cost is returned as a ShortNumberCost constant. ```php $phoneNumber = new \libphonenumber\PhoneNumber(); $phoneNumber->setCountryCode(44); $phoneNumber->setNationalNumber(118118); var_dump($shortNumberUtil->getExpectedCostForRegion($phoneNumber, 'GB')); // int(10) (\libphonenumber\ShortNumberCost::UNKNOWN_COST) var_dump($shortNumberUtil->getExpectedCostForRegion('24280', 'US')); // int(4) (\libphonenumber\ShortNumberCost::PREMIUM_RATE) ``` -------------------------------- ### Get Phone Number Type Source: https://github.com/giggsey/libphonenumber-for-php-lite/blob/main/docs/PhoneNumberUtil.md Determines and returns the type of the phone number (e.g., FIXED_LINE) as a PhoneNumberType constant. ```php var_dump($phoneNumberUtil->getNumberType($phoneNumberObject)); // int(0) (\libphonenumber\PhoneNumberType::FIXED_LINE) ``` -------------------------------- ### Get Region Code for Number Source: https://github.com/giggsey/libphonenumber-for-php-lite/blob/main/docs/PhoneNumberUtil.md Retrieves the region code associated with a given PhoneNumber object. ```php var_dump($phoneNumberUtil->getRegionCodeForNumber($phoneNumberObject)); // string(2) "GB" ``` -------------------------------- ### Get Expected Cost of Short Number Source: https://github.com/giggsey/libphonenumber-for-php-lite/blob/main/docs/ShortNumberInfo.md Returns the expected cost category (as a ShortNumberCost constant) for a given PhoneNumber short number in a specific region. The cost can be UNKNOWN_COST, PREMIUM_RATE, STANDARD_RATE, or TOLL_FREE. ```php $phoneNumber = new \libphonenumber\PhoneNumber(); $phoneNumber->setCountryCode(44); $phoneNumber->setNationalNumber(118118); var_dump($shortNumberUtil->getExpectedCost($phoneNumber, 'GB')); // int(10) (\libphonenumber\ShortNumberCost::UNKNOWN_COST) ``` -------------------------------- ### Get Country Code for Region Source: https://github.com/giggsey/libphonenumber-for-php-lite/blob/main/docs/PhoneNumberUtil.md Returns the country calling code associated with a specific region code. ```php var_dump($phoneNumberUtil->getCountryCodeForRegion('NZ')); // int(64) ``` -------------------------------- ### Get Timezones for a Geographically Tied Number Source: https://github.com/giggsey/libphonenumber-for-php-lite/blob/main/docs/PhoneNumberToTimeZonesMapper.md Demonstrates how to use `getTimeZonesForNumber()` with a specific US phone number to get its associated timezones. The output shows a single timezone for a geographically bound number. ```php $usNumber = \libphonenumber\PhoneNumberUtil::getInstance()->parse("+1 650 253 0000", "US"); var_dump($timezoneMapper->getTimeZonesForNumber($usNumber)); // array(1) { [0]=> string(19) "America/Los_Angeles" } ``` -------------------------------- ### Find Phone Numbers in Text Source: https://github.com/giggsey/libphonenumber-for-php-lite/blob/main/docs/PhoneNumberMatcher.md Finds and extracts telephone numbers from a given text. It returns a PhoneNumberMatcher instance that can be iterated to get PhoneNumberMatch objects. You can specify the default region and control the search leniency and maximum tries. ```php $phoneNumberUtil = \libphonenumber\PhoneNumberUtil::getInstance(); $text = "Hi, can you ring me at 1430 on 0117 496 0123. Thanks!"; $phoneNumberMatcher = $phoneNumberUtil->findNumbers($text, 'GB'); foreach ($phoneNumberMatcher as $phoneNumberMatch) { var_dump($phoneNumberMatch->number()); } // (PhoneNumber) Country Code: 44 National Number: 1174960123 ``` -------------------------------- ### Get Carrier Name for a Number Source: https://github.com/giggsey/libphonenumber-for-php-lite/blob/main/docs/PhoneNumberToCarrierMapper.md Retrieves the carrier name for a given PhoneNumber object in a specified language. It requires a parsed PhoneNumber object and a language code. ```php $chNumber = \libphonenumber\PhoneNumberUtil::getInstance()->parse("798765432", "CH"); var_dump($carrierMapper->getNameForNumber($chNumber, 'en')); // string(8) "Swisscom" ``` -------------------------------- ### Get Timezones for a Non-Geographically Tied Number Source: https://github.com/giggsey/libphonenumber-for-php-lite/blob/main/docs/PhoneNumberToTimeZonesMapper.md Illustrates the use of `getTimeZonesForNumber()` with a US Toll Free number. Toll-free numbers are not tied to a specific location, so the method returns an array of all possible US timezones. ```php $usNumber = \libphonenumber\PhoneNumberUtil::getInstance()->parse("+1 800 253 0000", "US"); var_dump($timezoneMapper->getTimeZonesForNumber($usNumber)); // array(35) { [0]=> string(16) "America/Anguilla" [1]=> string(15) "America/Antigua" [2]=> string(16) "America/Barbados" [3]=> string(14) "America/Cayman" [4]=> string(15) "America/Chicago" [5]=> string(14) "America/Denver" [6]=> string(16) "America/Dominica" [7]=> string(16) "America/Edmonton" [8]=> string(18) "America/Grand_Turk" [9]=> string(15) "America/Grenada" [10]=> string(15) "America/Halifax" [11]=> string(15) "America/Jamaica" [12]=> string(14) "America/Juneau" [13]=> string(19) "America/Los_Angeles" [14]=> string(21) "America/Lower_Princes" [15]=> string(18) "America/Montserrat" [16]=> string(14) "America/Nassau" [17]=> string(16) "America/New_York" [18]=> string(21) "America/Port_of_Spain" [19]=> string(19) "America/Puerto_Rico" [20]=> string(21) "America/Santo_Domingo" [21]=> string(16) "America/St_Johns" [22]=> string(16) "America/St_Kitts" [23]=> string(16) "America/St_Lucia" [24]=> string(17) "America/St_Thomas" [25]=> string(18) "America/St_Vincent" [26]=> string(15) "America/Toronto" [27]=> string(15) "America/Tortola" [28]=> string(17) "America/Vancouver" [29]=> string(16) "America/Winnipeg" [30]=> string(16) "Atlantic/Bermuda" [31]=> string(12) "Pacific/Guam" [32]=> string(16) "Pacific/Honolulu" [33]=> string(17) "Pacific/Pago_Pago" [34]=> string(14) "Pacific/Saipan" } ``` -------------------------------- ### Build Metadata Source: https://github.com/giggsey/libphonenumber-for-php-lite/blob/main/README.md Compiles the phone number metadata by cloning the Google libphonenumber project. This command is typically run via Composer. ```bash composer run build ``` -------------------------------- ### As You Type Formatter Usage Source: https://github.com/giggsey/libphonenumber-for-php-lite/blob/main/docs/AsYouTypeFormatter.md Demonstrates how to create an instance of the AsYouTypeFormatter and use the inputDigit method to format a phone number progressively. It shows the output after each digit is inputted. ```php $phoneNumberUtil = \libphonenumber\PhoneNumberUtil::getInstance(); $asYouTypeFormatter = $phoneNumberUtil->getAsYouTypeFormatter('GB'); $result = $asYouTypeFormatter->inputDigit('0'); var_dump($result); // string(1) "0" $result = $asYouTypeFormatter->inputDigit('1'); var_dump($result); // string(2) "01" $result = $asYouTypeFormatter->inputDigit('1'); var_dump($result); // string(3) "011" $result = $asYouTypeFormatter->inputDigit('7'); var_dump($result); // string(4) "0117" $result = $asYouTypeFormatter->inputDigit('4'); var_dump($result); // string(6) "0117 4" $result = $asYouTypeFormatter->inputDigit('9'); var_dump($result); // string(7) "0117 49" $result = $asYouTypeFormatter->inputDigit('6'); var_dump($result); // string(8) "0117 496" $result = $asYouTypeFormatter->inputDigit('0'); var_dump($result); // string(10) "0117 496 0" $result = $asYouTypeFormatter->inputDigit('1'); var_dump($result); // string(11) "0117 496 01" $result = $asYouTypeFormatter->inputDigit('2'); var_dump($result); // string(11) "01174 96012" $result = $asYouTypeFormatter->inputDigit('3'); var_dump($result); // string(13) "0117 496 0123" ``` -------------------------------- ### Parse and Validate Swiss Phone Number Source: https://github.com/giggsey/libphonenumber-for-php-lite/blob/main/README.md Demonstrates how to parse a phone number string for Switzerland, validate it, and display the resulting PhoneNumber object. It handles potential parsing errors. ```php $swissNumberStr = "044 668 18 00"; $phoneUtil = \libphonenumber\PhoneNumberUtil::getInstance(); try { $swissNumberProto = $phoneUtil->parse($swissNumberStr, "CH"); var_dump($swissNumberProto); } catch (\libphonenumber\NumberParseException $e) { var_dump($e); } ``` -------------------------------- ### Format Phone Number Source: https://github.com/giggsey/libphonenumber-for-php-lite/blob/main/docs/PhoneNumberUtil.md Formats a PhoneNumber object into various standard formats like E164, INTERNATIONAL, NATIONAL, and RFC3966. Requires a PhoneNumber object and a PhoneNumberFormat constant. ```php var_dump($phoneNumberUtil->format($phoneNumberObject, \libphonenumber\PhoneNumberFormat::E164)); // string(13) "+441174960123" var_dump($phoneNumberUtil->format($phoneNumberObject, \libphonenumber\PhoneNumberFormat::INTERNATIONAL)); // string(16) "+44 117 496 0123" var_dump($phoneNumberUtil->format($phoneNumberObject, \libphonenumber\PhoneNumberFormat::NATIONAL)); // string(13) "0117 496 0123" var_dump($phoneNumberUtil->format($phoneNumberObject, \libphonenumber\PhoneNumberFormat::RFC3966)); // string(20) "tel:+44-117-496-0123" ``` -------------------------------- ### Format Phone Number in National Format Source: https://github.com/giggsey/libphonenumber-for-php-lite/blob/main/README.md Formats a PhoneNumber object into the national dialing format for its region. ```php echo $phoneUtil->format($swissNumberProto, \libphonenumber\PhoneNumberFormat::NATIONAL); ``` -------------------------------- ### Format Phone Number in E.164 Format Source: https://github.com/giggsey/libphonenumber-for-php-lite/blob/main/README.md Formats a PhoneNumber object into the E.164 international standard format. ```php echo $phoneUtil->format($swissNumberProto, \libphonenumber\PhoneNumberFormat::E164); ``` -------------------------------- ### Format National Number with Preferred Carrier Code Source: https://github.com/giggsey/libphonenumber-for-php-lite/blob/main/docs/PhoneNumberUtil.md Formats a phone number in national format using the preferred domestic carrier code stored in the PhoneNumber object, or a fallback carrier code if the preferred one is missing. Use `formatNationalNumberWithCarrierCode()` if the provided carrier code should always take precedence. ```php $arNumber = new PhoneNumber(); $arNumber->setCountryCode(54)->setNationalNumber(91234125678); $arNumber->setPreferredDomesticCarrierCode("19"); var_dump($phoneNumberUtil->formatNationalNumberWithPreferredCarrierCode($arNumber, '15'); // string(16) "01234 19 12-5678" ``` -------------------------------- ### Format Out-of-Country Calling Number (GB) Source: https://github.com/giggsey/libphonenumber-for-php-lite/blob/main/README.md Formats a PhoneNumber object for dialing from Great Britain, including the necessary international access codes. ```php echo $phoneUtil->formatOutOfCountryCallingNumber($swissNumberProto, "GB"); ``` -------------------------------- ### Format Phone Number in International Format Source: https://github.com/giggsey/libphonenumber-for-php-lite/blob/main/README.md Formats a PhoneNumber object into the international dialing format. ```php echo $phoneUtil->format($swissNumberProto, \libphonenumber\PhoneNumberFormat::INTERNATIONAL); ``` -------------------------------- ### Format Out-of-Country Calling Number Source: https://github.com/giggsey/libphonenumber-for-php-lite/blob/main/docs/PhoneNumberUtil.md Formats a PhoneNumber object for dialing from a specified region. The output varies based on the region provided. ```php var_dump($phoneNumberUtil->formatOutOfCountryCallingNumber($phoneNumberObject, 'FR')); // string(18) "00 44 117 496 0123" var_dump($phoneNumberUtil->formatOutOfCountryCallingNumber($phoneNumberObject, 'US')); // string(19) "011 44 117 496 0123" var_dump($phoneNumberUtil->formatOutOfCountryCallingNumber($phoneNumberObject, 'GB')); // string(13) "0117 496 0123" ``` -------------------------------- ### Format Number for Mobile Dialing Source: https://github.com/giggsey/libphonenumber-for-php-lite/blob/main/docs/PhoneNumberUtil.md Formats a PhoneNumber object for dialing from a specific region, with an option to apply formatting. Returns an empty string if the number cannot be dialed from the specified region. ```php $australianPhoneNumberObject = $phoneNumberUtil->parse('1300123456', 'AU'); var_dump($phoneNumberUtil->formatNumberForMobileDialing($australianPhoneNumberObject, 'AU', true)); // string(12) "1300 123 456" var_dump($phoneNumberUtil->formatNumberForMobileDialing($australianPhoneNumberObject, 'AU', false)); // string(10) "1300123456" var_dump($phoneNumberUtil->formatNumberForMobileDialing($australianPhoneNumberObject, 'US', true)); // string(0) "" ``` -------------------------------- ### Format National Number with Carrier Code Source: https://github.com/giggsey/libphonenumber-for-php-lite/blob/main/docs/PhoneNumberUtil.md Formats a phone number in national format for dialing using a specified carrier code. If the carrier code is empty, it returns the number in national format without a carrier code. ```php $arPhoneNumberObject = $phoneNumberUtil->parse('92234654321', 'AR'); var_dump($phoneNumberUtil->formatNationalNumberWithCarrierCode($arPhoneNumberObject, 14); // string(16) "02234 14 65-4321" ``` -------------------------------- ### Check if Number is Possible Source: https://github.com/giggsey/libphonenumber-for-php-lite/blob/main/docs/PhoneNumberUtil.md Validates if a phone number is potentially possible. Accepts either a PhoneNumber object or a string and region code. ```php var_dump($phoneNumberUtil->isPossibleNumber($phoneNumberObject)); // bool(true) var_dump($phoneNumberUtil->isPossibleNumber('01174960123', 'GB')); // bool(true) ``` -------------------------------- ### Format Out-of-Country Calling Number (US) Source: https://github.com/giggsey/libphonenumber-for-php-lite/blob/main/README.md Formats a PhoneNumber object for dialing from the United States, including the necessary international access codes. ```php echo $phoneUtil->formatOutOfCountryCallingNumber($swissNumberProto, "US"); ``` -------------------------------- ### Check if Possible Short Number Source: https://github.com/giggsey/libphonenumber-for-php-lite/blob/main/docs/ShortNumberInfo.md Validates if a PhoneNumber object represents a possible short number. This is a preliminary check based on number patterns. ```php $phoneNumber = new \libphonenumber\PhoneNumber(); $phoneNumber->setCountryCode(44); $phoneNumber->setNationalNumber(118118); var_dump($shortNumberUtil->isPossibleShortNumber($phoneNumber)); // bool(true) ``` -------------------------------- ### Parse Phone Numbers Source: https://github.com/giggsey/libphonenumber-for-php-lite/blob/main/docs/PhoneNumberUtil.md Parses a phone number string into a PhoneNumber object. It can handle international formats or use a region code for national numbers. Throws NumberParseException on failure. ```php $phoneNumberUtil = \libphonenumber\PhoneNumberUtil::getInstance(); $phoneNumberObject = $phoneNumberUtil->parse('0117 496 0123', 'GB'); $phoneNumberObject = $phoneNumberUtil->parse('+44 117 496 0123', null); $phoneNumberObject = $phoneNumberUtil->parse('00 44 117 496 0123', 'FR'); $phoneNumberObject = $phoneNumberUtil->parse('117 496 0123', 'GB'); ``` -------------------------------- ### Check if Emergency Number Source: https://github.com/giggsey/libphonenumber-for-php-lite/blob/main/docs/ShortNumberInfo.md Determines if a given phone number string exactly matches an emergency service number for a specific region. It performs an exact match. ```php var_dump($shortNumberUtil->isEmergencyNumber('999', 'GB')); // bool(true) var_dump($shortNumberUtil->isEmergencyNumber('9999', 'GB')); // bool(false) ``` -------------------------------- ### Check if Possible Short Number for Region Source: https://github.com/giggsey/libphonenumber-for-php-lite/blob/main/docs/ShortNumberInfo.md Checks if a given short number (string or PhoneNumber object) is a possible short number for a specific region. It validates against regional patterns. ```php $phoneNumber = new \libphonenumber\PhoneNumber(); $phoneNumber->setCountryCode(44); $phoneNumber->setNationalNumber(118118); var_dump($shortNumberUtil->isPossibleShortNumberForRegion($phoneNumber, 'GB')); // bool(true) var_dump($shortNumberUtil->isPossibleShortNumberForRegion('1234', 'GB')); // bool(true) ``` -------------------------------- ### Check Number Possibility for Type Source: https://github.com/giggsey/libphonenumber-for-php-lite/blob/main/docs/PhoneNumberUtil.md Checks if a PhoneNumber object is a possible number for a specific PhoneNumberType. Returns a ValidationResult constant. ```php var_dump($phoneNumberUtil->isPossibleNumberForTypeWithReason($phoneNumberObject, \libphonenumber\PhoneNumberType::FIXED_LINE)); // int(0) (\libphonenumber\ValidationResult::IS_POSSIBLE) ``` -------------------------------- ### Check if Connects to Emergency Number Source: https://github.com/giggsey/libphonenumber-for-php-lite/blob/main/docs/ShortNumberInfo.md Verifies if dialing a given phone number might connect to an emergency service within a specified region. This allows for numbers with additional digits that might still reach emergency services. ```php var_dump($shortNumberUtil->connectsToEmergencyNumber('999', 'GB')); // bool(true) // Note, 999 is a GB emergency service, but additional digits after the 999 // might be possible to dial. var_dump($shortNumberUtil->connectsToEmergencyNumber('999123', 'GB')); // bool(true) ``` -------------------------------- ### Validate Phone Number Source: https://github.com/giggsey/libphonenumber-for-php-lite/blob/main/docs/PhoneNumberUtil.md Checks if a PhoneNumber object represents a valid phone number pattern. Note: This does not verify if the number is currently in use. ```php var_dump($phoneNumberUtil->isValidNumber($phoneNumberObject)); // bool(true) ``` -------------------------------- ### Validate Phone Number Object Source: https://github.com/giggsey/libphonenumber-for-php-lite/blob/main/README.md Checks if a given PhoneNumber object represents a valid phone number. Returns a boolean indicating validity. ```php $isValid = $phoneUtil->isValidNumber($swissNumberProto); var_dump($isValid); // true ``` -------------------------------- ### Check if Carrier Specific Source: https://github.com/giggsey/libphonenumber-for-php-lite/blob/main/docs/ShortNumberInfo.md Determines if a PhoneNumber object is a carrier-specific short number. This indicates the number might only be usable with a particular mobile carrier. ```php $phoneNumber = new \libphonenumber\PhoneNumber(); $phoneNumber->setCountryCode(1); $phoneNumber->setNationalNumber(611); var_dump($shortNumberUtil->isCarrierSpecific($phoneNumber)); // (bool) true ``` -------------------------------- ### Check International Dialing Capability Source: https://github.com/giggsey/libphonenumber-for-php-lite/blob/main/docs/PhoneNumberUtil.md Checks if a PhoneNumber object can be dialed internationally. Returns a boolean value. ```php var_dump($phoneNumberUtil->canBeInternationallyDialled($phoneNumberObject)); // bool(true) $australianPhoneNumberObject = $phoneNumberUtil->parse('1300123456', 'AU'); var_dump($phoneNumberUtil->canBeInternationallyDialled($australianPhoneNumberObject)); // bool(false) ``` -------------------------------- ### Validate Phone Number for Region Source: https://github.com/giggsey/libphonenumber-for-php-lite/blob/main/docs/PhoneNumberUtil.md Checks if a PhoneNumber object is valid for a specific region. Note: This does not verify if the number is currently in use. ```php var_dump($phoneNumberUtil->isValidNumberForRegion($phoneNumberObject, 'FR')); // bool(false) ``` -------------------------------- ### Check if Valid Short Number Source: https://github.com/giggsey/libphonenumber-for-php-lite/blob/main/docs/ShortNumberInfo.md Validates if a PhoneNumber object represents a valid short number. Note: This function only checks against known number patterns and does not confirm if the number is actively in use. ```php $phoneNumber = new \libphonenumber\PhoneNumber(); $phoneNumber->setCountryCode(44); $phoneNumber->setNationalNumber(118118); var_dump($shortNumberUtil->isValidShortNumber($phoneNumber)); // bool(true) ``` -------------------------------- ### Check if Valid Short Number for Region Source: https://github.com/giggsey/libphonenumber-for-php-lite/blob/main/docs/ShortNumberInfo.md Checks if a given short number (string or PhoneNumber object) is a valid short number for a specific region. Similar to isValidShortNumber, it validates patterns but not active usage. ```php $phoneNumber = new \libphonenumber\PhoneNumber(); $phoneNumber->setCountryCode(44); $phoneNumber->setNationalNumber(118118); var_dump($shortNumberUtil->isValidShortNumberForRegion($phoneNumber, 'GB')); // bool(true) var_dump($shortNumberUtil->isValidShortNumberForRegion('1234', 'GB')); // bool(false) ``` -------------------------------- ### Check if Carrier Specific for Region Source: https://github.com/giggsey/libphonenumber-for-php-lite/blob/main/docs/ShortNumberInfo.md Checks if a PhoneNumber object is a carrier-specific short number within a given region. This is useful for identifying numbers tied to specific regional carriers. ```php $phoneNumber = new \libphonenumber\PhoneNumber(); $phoneNumber->setCountryCode(1); $phoneNumber->setNationalNumber(611); var_dump($shortNumberUtil->isCarrierSpecificForRegion($phoneNumber, 'US')); // (bool) true ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.