PHP Класс Punic\Territory

Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
getChildTerritoryCodes ( string $parentTerritoryCode, boolean $expandSubGroups = false ) : array Retrieve the child territories of a parent territory.
getContinents ( string $locale = '' ) : array Return the list of continents in the form of an array with key=ID, value=name.
getContinentsAndCountries ( string $locale = '' ) : array Return a list of continents and relative countries. The resulting array is in the following form (JSON representation): ```json { "002": { "name": "Africa", "children": { "DZ": {"name": "Algeria"}, "AO": {"name": "Angola"}, .
getCountries ( string $locale = '' ) : array Return the list of countries in the form of an array with key=ID, value=name.
getGrossDomesticProduct ( string $territoryCode ) : number | null Return the GDP (Gross Domestic Product) for a specific territory, in US$.
getLanguages ( string $territoryCode, string $filterStatuses = '', string $onlyCodes = false ) : array | null Return the list of languages spoken in a territory.
getList ( string $levels = 'W', string $locale = '' ) : array Return a list of some specified territory, structured or not.
getLiteracyLevel ( string $territoryCode ) : number | null Return the literacy level for a specific territory, in %.
getName ( string $territoryCode, string $locale = '' ) : string Retrieve the name of a territory (country, continent, .
getParentTerritoryCode ( string $childTerritoryCode ) : string Return the code of the territory that contains a territory.
getPopulation ( string $territoryCode ) : number | null Return the population of a specific territory.
getTerritoriesForLanguage ( string $languageID, float $threshold ) : array Return a list of territory IDs where a specific language is spoken, sorted by the total number of people speaking that language.
getTerritoriesWithInfo ( ) : array Return a list of territory identifiers for which we have some info (languages, population, literacy level, Gross Domestic Product).

Защищенные методы

Метод Описание
fillStructure ( $data, $id, $level )
filterStructure ( $parent, $levels )
finalizeWithNames ( $data, $list, $flatList )
getStructure ( )
getTerritoryInfo ( $territoryCode )
sort ( $list )

Описание методов

fillStructure() защищенный статический Метод

protected static fillStructure ( $data, $id, $level )

filterStructure() защищенный статический Метод

protected static filterStructure ( $parent, $levels )

finalizeWithNames() защищенный статический Метод

protected static finalizeWithNames ( $data, $list, $flatList )

getChildTerritoryCodes() публичный статический Метод

Retrieve the child territories of a parent territory.
public static getChildTerritoryCodes ( string $parentTerritoryCode, boolean $expandSubGroups = false ) : array
$parentTerritoryCode string
$expandSubGroups boolean Set to true to expand the sub-groups, false to retrieve them.
Результат array Return the list of territory codes that are children of $parentTerritoryCode (if $parentTerritoryCode is invalid you'll get an empty list)

getContinents() публичный статический Метод

Return the list of continents in the form of an array with key=ID, value=name.
public static getContinents ( string $locale = '' ) : array
$locale string The locale to use. If empty we'll use the default locale set in \Punic\Data
Результат array

getContinentsAndCountries() публичный статический Метод

.. } }, "150": { "name": "Europe", "children": { "AL": {"name": "Albania"}, "AD": {"name": "Andorra"}, ... } } ... } ``` The arrays are sorted by territory name.
public static getContinentsAndCountries ( string $locale = '' ) : array
$locale string The locale to use. If empty we'll use the default locale set in \Punic\Data
Результат array

getCountries() публичный статический Метод

Return the list of countries in the form of an array with key=ID, value=name.
public static getCountries ( string $locale = '' ) : array
$locale string The locale to use. If empty we'll use the default locale set in \Punic\Data
Результат array

getGrossDomesticProduct() публичный статический Метод

Return the GDP (Gross Domestic Product) for a specific territory, in US$.
public static getGrossDomesticProduct ( string $territoryCode ) : number | null
$territoryCode string The territory code
Результат number | null Return the GDP of the specified territory (or null if $territoryCode is not valid or no data is available)

getLanguages() публичный статический Метод

Return the list of languages spoken in a territory.
public static getLanguages ( string $territoryCode, string $filterStatuses = '', string $onlyCodes = false ) : array | null
$territoryCode string The territory code
$filterStatuses string Filter language status.
  • If empty no filter will be applied
  • 'o' to include official languages
  • 'r' to include official regional languages
  • 'f' to include de facto official languages
  • 'm' to include official minority languages
  • 'u' to include unofficial or unknown languages
$onlyCodes string Set to true to retrieve only the language codes. If set to false (default) you'll receive a list of arrays with these keys:
  • string id: the language identifier
  • string status: 'o' for official; 'r' for official regional; 'f' for de facto official; 'm' for official minority; 'u' for unofficial or unknown
  • number population: the amount of people speaking the language (%)
  • number|null writing: the amount of people able to write (%). May be null if no data is available
Результат array | null Return the languages spoken in the specified territory, as described by the $onlyCodes parameter (or null if $territoryCode is not valid or no data is available)

getList() публичный статический Метод

$levels control which data you want to retrieve. It can be one or more of the following values:
  • 'W': world
  • 'C': continents
  • 'S': sub-continents
  • 'c': countries
If only one level is specified you'll get a flat list (like the one returned by {@link getContinents}). If one or more levels are specified, you'll get a structured list (like the one returned by {@link getContinentsAndCountries}).
public static getList ( string $levels = 'W', string $locale = '' ) : array
$levels string A string with one or more of the characters: 'W' (for world), 'C' (for continents), 'S' (for sub-continents), 'c' (for countries)
$locale string The locale to use. If empty we'll use the default locale set in \Punic\Data
Результат array

getLiteracyLevel() публичный статический Метод

Return the literacy level for a specific territory, in %.
public static getLiteracyLevel ( string $territoryCode ) : number | null
$territoryCode string The territory code
Результат number | null Return the % of literacy lever of the specified territory (or null if $territoryCode is not valid or no data is available)

getName() публичный статический Метод

..).
public static getName ( string $territoryCode, string $locale = '' ) : string
$territoryCode string The territory code
$locale string The locale to use. If empty we'll use the default locale set in \Punic\Data
Результат string Returns the localized territory name (returns $territoryCode if not found)

getParentTerritoryCode() публичный статический Метод

Return the code of the territory that contains a territory.
public static getParentTerritoryCode ( string $childTerritoryCode ) : string
$childTerritoryCode string
Результат string Return the parent territory code, or an empty string if $childTerritoryCode is the World (001) or if it's invalid.

getPopulation() публичный статический Метод

Return the population of a specific territory.
public static getPopulation ( string $territoryCode ) : number | null
$territoryCode string The territory code
Результат number | null Return the size of the population of the specified territory (or null if $territoryCode is not valid or no data is available)

getStructure() защищенный статический Метод

protected static getStructure ( )

getTerritoriesForLanguage() публичный статический Метод

Return a list of territory IDs where a specific language is spoken, sorted by the total number of people speaking that language.
public static getTerritoriesForLanguage ( string $languageID, float $threshold ) : array
$languageID string The language identifier
$threshold float The minimum percentage (from 0 to 100) to consider a language as spoken in a Country
Результат array

getTerritoriesWithInfo() публичный статический Метод

Return a list of territory identifiers for which we have some info (languages, population, literacy level, Gross Domestic Product).
public static getTerritoriesWithInfo ( ) : array
Результат array The list of territory IDs for which we have some info

getTerritoryInfo() защищенный статический Метод

protected static getTerritoryInfo ( $territoryCode )

sort() защищенный статический Метод

protected static sort ( $list )