PHP Class Monarobase\CountryList\CountryList

Author: Monarobase ([email protected])
Afficher le fichier Open project: monarobase/country-list

Protected Properties

Свойство Type Description
$dataCache array Cached data.
$dataDir string Path to the directory containing countries data.
$dataSources array Available data sources.

Méthodes publiques

Méthode Description
__construct ( string | null $dataDir = null ) Constructor.
getDataDir ( ) : string
getList ( string $locale = 'en', string $format = 'php', string $source = 'cldr' ) : array Returns a list of countries.
getOne ( string $countryCode, string $locale = 'en', string $source = 'cldr' ) : string Returns one country.
has ( string $countryCode, string $locale = 'en', string $source = 'cldr' ) : boolean Indicates whether or not a given $countryCode matches a country.
setList ( string $locale, string $source, array $data ) : CountryList

Méthodes protégées

Méthode Description
loadData ( string $locale, string $source, string $format ) : array A lazy-loader that loads data from a PHP file if it is not stored in memory yet.
sortData ( string $locale, array $data ) : array Sorts the data array for a given locale, using the locale translations.

Method Details

__construct() public méthode

Constructor.
public __construct ( string | null $dataDir = null )
$dataDir string | null Path to the directory containing countries data

getDataDir() public méthode

public getDataDir ( ) : string
Résultat string The country data directory.

getList() public méthode

Returns a list of countries.
public getList ( string $locale = 'en', string $format = 'php', string $source = 'cldr' ) : array
$locale string The locale (default: en)
$format string The format (default: php)
$source string Data source: "icu" or "cldr"
Résultat array

getOne() public méthode

Returns one country.
public getOne ( string $countryCode, string $locale = 'en', string $source = 'cldr' ) : string
$countryCode string The country
$locale string The locale (default: en)
$source string Data source: "icu" or "cldr"
Résultat string

has() public méthode

Indicates whether or not a given $countryCode matches a country.
public has ( string $countryCode, string $locale = 'en', string $source = 'cldr' ) : boolean
$countryCode string A 2-letter country code
$locale string The locale (default: en)
$source string Data source: "icu" or "cldr"
Résultat boolean true if a match was found, false otherwise

loadData() protected méthode

A lazy-loader that loads data from a PHP file if it is not stored in memory yet.
protected loadData ( string $locale, string $source, string $format ) : array
$locale string The locale
$source string Data source
$format string The format (default: php)
Résultat array An array (list) with country

setList() public méthode

public setList ( string $locale, string $source, array $data ) : CountryList
$locale string The locale
$source string Data source
$data array An array (list) with country data
Résultat CountryList The instance of CountryList to enable fluent interface

sortData() protected méthode

It is UTF-8 aware if the Collator class is available (requires the intl extension).
protected sortData ( string $locale, array $data ) : array
$locale string The locale whose collation rules should be used.
$data array Array of strings to sort.
Résultat array The $data array, sorted.

Property Details

$dataCache protected_oe property

Cached data.
protected array $dataCache
Résultat array

$dataDir protected_oe property

Path to the directory containing countries data.
protected string $dataDir
Résultat string

$dataSources protected_oe property

Available data sources.
protected array $dataSources
Résultat array