PHP Class CommerceGuys\Addressing\LocaleHelper

Show file Open project: commerceguys/addressing Class Usage Examples

Public Methods

Method Description
canonicalize ( string $locale = null ) : string Canonicalize the given locale.
getVariants ( string $locale ) : array Gets all variants of a locale.
match ( string $firstLocale, string $secondLocale ) : boolean Checks whether the two locales match.

Method Details

canonicalize() public static method

Canonicalize the given locale.
public static canonicalize ( string $locale = null ) : string
$locale string The locale.
return string The canonicalized locale.

getVariants() public static method

For example, "bs-Cyrl-BA" has the following variants: 1) bs-Cyrl-BA 2) bs-Cyrl 3) bs
public static getVariants ( string $locale ) : array
$locale string The locale (i.e. fr-FR).
return array An array of all variants of a locale.

match() public static method

Checks whether the two locales match.
public static match ( string $firstLocale, string $secondLocale ) : boolean
$firstLocale string The first locale.
$secondLocale string The second locale.
return boolean TRUE if the locales match, FALSE otherwise.