PHP Class libphonenumber\PhoneNumber

Datei anzeigen Open project: giggsey/libphonenumber-for-php Class Usage Examples

Protected Properties

Property Type Description
$countryCode integer | null The country calling code for this number, as defined by the International Telecommunication Union (ITU). For example, this would be 1 for NANPA countries, and 33 for France.
$countryCodeSource integer | null The source from which the country_code is derived. This is not set in the general parsing method, but in the method that parses and keeps raw_input. New fields could be added upon request.
$extension string | null Extension is not standardized in ITU recommendations, except for being defined as a series of numbers with a maximum length of 40 digits. It is defined as a string here to accommodate for the possible use of a leading zero in the extension (organizations have complete freedom to do so, as there is no standard defined). However, only ASCII digits should be stored here.
$hasNumberOfLeadingZeros boolean Whether this phone number has a number of leading zeros set.
$italianLeadingZero boolean | null There have been plans to migrate fixed-line numbers to start with the digit two since December 2000, but it has not happened yet. See http://en.wikipedia.org/wiki/%2B39 for more details. These fields can be safely ignored (there is no need to set them) for most countries. Some limited number of countries behave like Italy - for these cases, if the leading zero(s) of a number would be retained even when dialling internationally, set this flag to true, and also set the number of leading zeros. Clients who use the parsing functionality of the i18n phone number libraries will have these fields set if necessary automatically.
$nationalNumber string | null Note that the National (significant) Number does not contain the National(trunk) prefix.
$numberOfLeadingZeros integer The number of leading zeros of this phone number.
$preferredDomesticCarrierCode string | null Note this is the "preferred" code, which means other codes may work as well.
$rawInput string | null This field is used to store the raw input string containing phone numbers before it was canonicalized by the library. For example, it could be used to store alphanumerical numbers such as "1-800-GOOG-411".

Public Methods

Method Description
__toString ( ) : string Returns a string representation of this phone number.
clear ( ) : PhoneNumber Clears this phone number.
clearCountryCode ( ) : PhoneNumber Clears the country code of this phone number.
clearCountryCodeSource ( ) : PhoneNumber Clears the country code source of this phone number.
clearExtension ( ) : PhoneNumber Clears the extension of this phone number.
clearItalianLeadingZero ( ) : PhoneNumber Clears the italian leading zero information of this phone number.
clearNationalNumber ( ) : PhoneNumber Clears the national number of this phone number.
clearNumberOfLeadingZeros ( ) : PhoneNumber Clears the number of leading zeros of this phone number.
clearPreferredDomesticCarrierCode ( ) : PhoneNumber Clears the preferred domestic carrier code of this phone number.
clearRawInput ( ) : PhoneNumber Clears the raw input of this phone number.
equals ( PhoneNumber $other ) : boolean Returns whether this phone number is equal to another.
getCountryCode ( ) : integer | null Returns the country code of this phone number.
getCountryCodeSource ( ) : integer | null Returns the country code source of this phone number.
getExtension ( ) : string | null Returns the extension of this phone number.
getNationalNumber ( ) : string | null Returns the country code of this phone number.
getNumberOfLeadingZeros ( ) : integer Returns the number of leading zeros of this phone number.
getPreferredDomesticCarrierCode ( ) : string | null Returns the preferred domestic carrier code of this phone number.
getRawInput ( ) : string | null Returns the raw input of this phone number.
hasCountryCode ( ) : boolean Returns whether this phone number has a country code set.
hasCountryCodeSource ( ) : boolean Returns whether this phone number has a country code source.
hasExtension ( ) : boolean Returns whether this phone number has an extension set.
hasItalianLeadingZero ( ) : boolean Returns whether this phone number has the italian leading zero information set.
hasNationalNumber ( ) : boolean Returns whether this phone number has a national number set.
hasNumberOfLeadingZeros ( ) : boolean Returns whether this phone number has a number of leading zeros set.
hasPreferredDomesticCarrierCode ( ) : boolean Returns whether this phone number has a preferred domestic carrier code.
hasRawInput ( ) : boolean Returns whether this phone number has a raw input.
isItalianLeadingZero ( ) : boolean | null Returns whether this phone number uses an italian leading zero.
mergeFrom ( PhoneNumber $other ) : PhoneNumber Merges the information from another phone number into this phone number.
serialize ( )
setCountryCode ( integer $value ) : PhoneNumber Sets the country code of this phone number.
setCountryCodeSource ( integer $value ) : PhoneNumber Sets the country code source of this phone number.
setExtension ( string $value ) : PhoneNumber Sets the extension of this phone number.
setItalianLeadingZero ( boolean $value ) : PhoneNumber Sets whether this phone number uses an italian leading zero.
setNationalNumber ( string $value ) : PhoneNumber Sets the national number of this phone number.
setNumberOfLeadingZeros ( integer $value ) : PhoneNumber Sets the number of leading zeros of this phone number.
setPreferredDomesticCarrierCode ( string $value ) : PhoneNumber Sets the preferred domestic carrier code of this phone number.
setRawInput ( string $value ) : PhoneNumber Sets the raw input of this phone number.
unserialize ( $serialized )

Method Details

__toString() public method

Returns a string representation of this phone number.
public __toString ( ) : string
return string

clear() public method

This effectively resets this phone number to the state of a new instance.
public clear ( ) : PhoneNumber
return PhoneNumber This PhoneNumber instance, for chaining method calls.

clearCountryCode() public method

Clears the country code of this phone number.
public clearCountryCode ( ) : PhoneNumber
return PhoneNumber This PhoneNumber instance, for chaining method calls.

clearCountryCodeSource() public method

Clears the country code source of this phone number.
public clearCountryCodeSource ( ) : PhoneNumber
return PhoneNumber This PhoneNumber instance, for chaining method calls.

clearExtension() public method

Clears the extension of this phone number.
public clearExtension ( ) : PhoneNumber
return PhoneNumber This PhoneNumber instance, for chaining method calls.

clearItalianLeadingZero() public method

Clears the italian leading zero information of this phone number.
public clearItalianLeadingZero ( ) : PhoneNumber
return PhoneNumber This PhoneNumber instance, for chaining method calls.

clearNationalNumber() public method

Clears the national number of this phone number.
public clearNationalNumber ( ) : PhoneNumber
return PhoneNumber This PhoneNumber instance, for chaining method calls.

clearNumberOfLeadingZeros() public method

Clears the number of leading zeros of this phone number.
public clearNumberOfLeadingZeros ( ) : PhoneNumber
return PhoneNumber This PhoneNumber instance, for chaining method calls.

clearPreferredDomesticCarrierCode() public method

Clears the preferred domestic carrier code of this phone number.
public clearPreferredDomesticCarrierCode ( ) : PhoneNumber
return PhoneNumber This PhoneNumber instance, for chaining method calls.

clearRawInput() public method

Clears the raw input of this phone number.
public clearRawInput ( ) : PhoneNumber
return PhoneNumber This PhoneNumber instance, for chaining method calls.

equals() public method

Returns whether this phone number is equal to another.
public equals ( PhoneNumber $other ) : boolean
$other PhoneNumber The phone number to compare.
return boolean True if the phone numbers are equal, false otherwise.

getCountryCode() public method

Returns the country code of this phone number.
public getCountryCode ( ) : integer | null
return integer | null The country code, or null if not set.

getCountryCodeSource() public method

Returns the country code source of this phone number.
public getCountryCodeSource ( ) : integer | null
return integer | null A CountryCodeSource constant, or null if not set.

getExtension() public method

Returns the extension of this phone number.
public getExtension ( ) : string | null
return string | null The extension, or null if not set.

getNationalNumber() public method

Returns the country code of this phone number.
public getNationalNumber ( ) : string | null
return string | null The national number, or null if not set.

getNumberOfLeadingZeros() public method

Returns the number of leading zeros of this phone number.
public getNumberOfLeadingZeros ( ) : integer
return integer The number of leading zeros.

getPreferredDomesticCarrierCode() public method

Returns the preferred domestic carrier code of this phone number.
public getPreferredDomesticCarrierCode ( ) : string | null
return string | null The preferred domestic carrier code, or null if not set.

getRawInput() public method

Returns the raw input of this phone number.
public getRawInput ( ) : string | null
return string | null The raw input, or null if not set.

hasCountryCode() public method

Returns whether this phone number has a country code set.
public hasCountryCode ( ) : boolean
return boolean True if a country code is set, false otherwise.

hasCountryCodeSource() public method

Returns whether this phone number has a country code source.
public hasCountryCodeSource ( ) : boolean
return boolean True if a country code source is set, false otherwise.

hasExtension() public method

Returns whether this phone number has an extension set.
public hasExtension ( ) : boolean
return boolean True if an extension is set, false otherwise.

hasItalianLeadingZero() public method

Returns whether this phone number has the italian leading zero information set.
public hasItalianLeadingZero ( ) : boolean
return boolean

hasNationalNumber() public method

Returns whether this phone number has a national number set.
public hasNationalNumber ( ) : boolean
return boolean True if a national number is set, false otherwise.

hasNumberOfLeadingZeros() public method

Returns whether this phone number has a number of leading zeros set.
public hasNumberOfLeadingZeros ( ) : boolean
return boolean True if a number of leading zeros is set, false otherwise.

hasPreferredDomesticCarrierCode() public method

Returns whether this phone number has a preferred domestic carrier code.
public hasPreferredDomesticCarrierCode ( ) : boolean
return boolean True if a preferred domestic carrier code is set, false otherwise.

hasRawInput() public method

Returns whether this phone number has a raw input.
public hasRawInput ( ) : boolean
return boolean True if a raw input is set, false otherwise.

isItalianLeadingZero() public method

Returns whether this phone number uses an italian leading zero.
public isItalianLeadingZero ( ) : boolean | null
return boolean | null True if it uses an italian leading zero, false it it does not, null if not set.

mergeFrom() public method

Merges the information from another phone number into this phone number.
public mergeFrom ( PhoneNumber $other ) : PhoneNumber
$other PhoneNumber The phone number to copy.
return PhoneNumber This PhoneNumber instance, for chaining method calls.

serialize() public method

public serialize ( )

setCountryCode() public method

Sets the country code of this phone number.
public setCountryCode ( integer $value ) : PhoneNumber
$value integer The country code.
return PhoneNumber This PhoneNumber instance, for chaining method calls.

setCountryCodeSource() public method

Sets the country code source of this phone number.
public setCountryCodeSource ( integer $value ) : PhoneNumber
$value integer A CountryCodeSource constant.
return PhoneNumber This PhoneNumber instance, for chaining method calls.

setExtension() public method

Sets the extension of this phone number.
public setExtension ( string $value ) : PhoneNumber
$value string The extension.
return PhoneNumber This PhoneNumber instance, for chaining method calls.

setItalianLeadingZero() public method

Sets whether this phone number uses an italian leading zero.
public setItalianLeadingZero ( boolean $value ) : PhoneNumber
$value boolean True to use italian leading zero, false otherwise.
return PhoneNumber This PhoneNumber instance, for chaining method calls.

setNationalNumber() public method

Sets the national number of this phone number.
public setNationalNumber ( string $value ) : PhoneNumber
$value string The national number.
return PhoneNumber This PhoneNumber instance, for chaining method calls.

setNumberOfLeadingZeros() public method

Sets the number of leading zeros of this phone number.
public setNumberOfLeadingZeros ( integer $value ) : PhoneNumber
$value integer The number of leading zeros.
return PhoneNumber This PhoneNumber instance, for chaining method calls.

setPreferredDomesticCarrierCode() public method

Sets the preferred domestic carrier code of this phone number.
public setPreferredDomesticCarrierCode ( string $value ) : PhoneNumber
$value string The preferred domestic carrier code.
return PhoneNumber This PhoneNumber instance, for chaining method calls.

setRawInput() public method

Sets the raw input of this phone number.
public setRawInput ( string $value ) : PhoneNumber
$value string The raw input.
return PhoneNumber This PhoneNumber instance, for chaining method calls.

unserialize() public method

public unserialize ( $serialized )

Property Details

$countryCode protected_oe property

The country calling code for this number, as defined by the International Telecommunication Union (ITU). For example, this would be 1 for NANPA countries, and 33 for France.
protected int|null $countryCode
return integer | null

$countryCodeSource protected_oe property

The source from which the country_code is derived. This is not set in the general parsing method, but in the method that parses and keeps raw_input. New fields could be added upon request.
See also: CountryCodeSource This must be one of the CountryCodeSource constants.
protected int|null $countryCodeSource
return integer | null

$extension protected_oe property

Extension is not standardized in ITU recommendations, except for being defined as a series of numbers with a maximum length of 40 digits. It is defined as a string here to accommodate for the possible use of a leading zero in the extension (organizations have complete freedom to do so, as there is no standard defined). However, only ASCII digits should be stored here.
protected string|null $extension
return string | null

$hasNumberOfLeadingZeros protected_oe property

Whether this phone number has a number of leading zeros set.
protected bool $hasNumberOfLeadingZeros
return boolean

$italianLeadingZero protected_oe property

There have been plans to migrate fixed-line numbers to start with the digit two since December 2000, but it has not happened yet. See http://en.wikipedia.org/wiki/%2B39 for more details. These fields can be safely ignored (there is no need to set them) for most countries. Some limited number of countries behave like Italy - for these cases, if the leading zero(s) of a number would be retained even when dialling internationally, set this flag to true, and also set the number of leading zeros. Clients who use the parsing functionality of the i18n phone number libraries will have these fields set if necessary automatically.
protected bool|null $italianLeadingZero
return boolean | null

$nationalNumber protected_oe property

Note that the National (significant) Number does not contain the National(trunk) prefix.
protected string|null $nationalNumber
return string | null

$numberOfLeadingZeros protected_oe property

The number of leading zeros of this phone number.
protected int $numberOfLeadingZeros
return integer

$preferredDomesticCarrierCode protected_oe property

Note this is the "preferred" code, which means other codes may work as well.
protected string|null $preferredDomesticCarrierCode
return string | null

$rawInput protected_oe property

This field is used to store the raw input string containing phone numbers before it was canonicalized by the library. For example, it could be used to store alphanumerical numbers such as "1-800-GOOG-411".
protected string|null $rawInput
return string | null