PHP Class RegionCode, googleads-php-lib

See: http://unicode.org/cldr/charts/supplemental/territory_containment_un_m_49.html

It contains no behavior, but is the authoritative definition of Region identity in java Google code.

Do:

  • use it everywhere you need to compare regions
  • use it in all APIs that take/return a region (such as a country), particularly all public APIs
  • get the instance corresponding to an CLDR code using {@link #forString}
  • get the String CLDR code with {@link #toString}
  • use the String CLDR code in your DB as a key to currencies
  • if your API supports only a subset of these codes, make sure to validate (e.g. by creating an EnumSet and using Precondition)
  • put your project-specific region-related information in a class under your project root, using an EnumMap or BiMap to map these Regions to your objects.
Do not:
  • depend on the ordinal of a region, for example using {@link #ordinal()} or depending on the index of a particular region in the {@link #values} array.
  • depend on the comparison order of regions, via {@link Enum#compareTo(Enum)}), or via the iteration order of an EnumSet, etc.
  • use {@link #valueOf} or {@link #name()}. The CLDR numeric codes aren't valid for java, so they were prepended by "UN" (as in "UN001" for the CLDR code "001").
  • assume that these are the same as the two-letter ISO codes. Oftentimes they will be, but CLDR guarantees stability, so ISO codes that change will be different from the entries in this enum.
This enum does not:
  • have i18n features
  • have application-specific data
These concerns will be addressed by other classes, some in application-specific packages, others in common.base.i18n. The latter ones will be listed with "see" tags in this class. This class does not supply methods for getting information about regions. For those methods, see {@link RegionInfo}.

Note that not all regions have a "two-letter" country code. Instead, some have a three digit number -- the UN M.49 (United Nations) area code. These are the enum items prepended with "UN". See:

  • http://unstats.un.org/unsd/methods/m49/m49alpha.htm
  • http://unstats.un.org/unsd/methods/m49/m49.htm

Also note that CLDR -- contrary to ISO -- guarantees non-reuse of country codes. Thus, though most times CLDR codes are the same as the ISO codes, sometimes they are not.

Datei anzeigen Open project: googleads/googleads-php-lib

Public Methods

Method Description
__construct ( )
getNamespace ( ) : string Gets the namesapce of this class
getXsiTypeName ( ) : string Gets the xsi:type name of this class

Method Details

__construct() public method

public __construct ( )

getNamespace() public method

Gets the namesapce of this class
public getNamespace ( ) : string
return string the namespace of this class

getXsiTypeName() public method

Gets the xsi:type name of this class
public getXsiTypeName ( ) : string
return string the xsi:type name of this class