Nextcloud PHP API (master)

IPhoneNumberUtil

Tags
since
28.0.0

Table of Contents

Methods

convertToStandardFormat()  : string|null
Converts a given input into an E164 formatted phone number
getCountryCodeForRegion()  : int|null
Returns the country code for a specific region

Methods

convertToStandardFormat()

Converts a given input into an E164 formatted phone number

public convertToStandardFormat(string $input[, string|null $defaultRegion = null ]) : string|null

E164 is the international format without any formatting characters or spaces. E.g. +41446681800 where +41 is the region code.

Parameters
$input : string

Input phone number can contain formatting spaces, slashes and dashes

$defaultRegion : string|null = null

Two-letter region code of ISO 3166-1

Tags
since
28.0.0
Return values
string|null

Null when the input is invalid for the given region or requires a region.

getCountryCodeForRegion()

Returns the country code for a specific region

public getCountryCodeForRegion(string $regionCode) : int|null

For example, this would be 41 for Switzerland and 49 for Germany. Returns null when the region is invalid.

Parameters
$regionCode : string

Two-letter region code of ISO 3166-1

Tags
since
28.0.0
Return values
int|null

Null when invalid/unsupported, the phone country code otherwise


        
On this page

Search results