PHP 클래스 Punic\Territory

파일 보기 프로젝트 열기: punic/punic 1 사용 예제들

공개 메소드들

메소드 설명
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 )