public static
|
#
getAvailableUnits( string $locale = '' )
Get the list of all the available units.
Get the list of all the available units.
Parameters
- $locale
- The locale to use. If empty we'll use the default locale set in \Punic\Data
|
public static
string
|
#
getName( string $unit, string $width = 'short', string $locale = '' )
Get the localized name of a unit.
Get the localized name of a unit.
Parameters
- $unit
- The unit identifier (eg 'duration/millisecond' or 'millisecond')
- $width
- The format name; it can be 'long' ('milliseconds'), 'short' (eg 'millisecs') or 'narrow' (eg 'msec')
- $locale
- The locale to use. If empty we'll use the default locale set in \Punic\Data
Returns
string
Throws
|
public static
string
|
#
format( integer|float|string $number, string $unit, string $width = 'short', string $locale = '' )
Format a unit string.
Parameters
- $number
- The unit amount
- $unit
- The unit identifier (eg 'duration/millisecond' or 'millisecond')
- $width
- The format name; it can be 'long' (eg '3 milliseconds'), 'short' (eg '3 ms') or 'narrow' (eg '3ms'). You can also add a precision specifier ('long,2' or just '2')
- $locale
- The locale to use. If empty we'll use the default locale set in \Punic\Data
Returns
string
Throws
|
public static
array
|
#
getMeasurementSystems( string $locale = '' )
Retrieve the measurement systems and their localized names.
Retrieve the measurement systems and their localized names.
Parameters
- $locale
- The locale to use. If empty we'll use the default locale set in \Punic\Data
Returns
array The array keys are the measurement system codes (eg 'metric', 'US', 'UK'), the values are the localized measurement system names (eg 'Metric', 'US', 'UK' for English)
|
public static
string
|
#
getMeasurementSystemFor( string $territoryCode )
Retrieve the measurement system for a specific territory.
Retrieve the measurement system for a specific territory.
Parameters
- $territoryCode
- The territory code (eg. 'US' for 'United States of America').
Returns
string Return the measurement system code (eg: 'metric') for the specified territory. If $territoryCode is not valid we'll return an empty string.
|
public static
array
|
#
getCountriesWithMeasurementSystem( string $measurementSystem )
Returns the list of countries that use a specific measurement system.
Returns the list of countries that use a specific measurement system.
Parameters
- $measurementSystem
- The measurement system identifier ('metric', 'US' or 'UK')
Returns
array The list of country IDs that use the specified measurement system (if $measurementSystem is invalid you'll get an empty array)
|
public static
string
|
#
getPaperSizeFor( string $territoryCode )
Retrieve the standard paper size for a specific territory.
Retrieve the standard paper size for a specific territory.
Parameters
- $territoryCode
- The territory code (eg. 'US' for 'United States of America').
Returns
string Return the standard paper size (eg: 'A4' or 'US-Letter') for the specified territory. If $territoryCode is not valid we'll return an empty string.
|
public static
array
|
#
getCountriesWithPaperSize( string $paperSize )
Returns the list of countries that use a specific paper size by default.
Returns the list of countries that use a specific paper size by default.
Parameters
- $paperSize
- The paper size identifier ('A4' or 'US-Letter')
Returns
array The list of country IDs that use the specified paper size (if $paperSize is invalid you'll get an empty array)
|