public static
boolean
|
#
isNumeric( string $value, string $locale = '' )
Check if a variable contains a valid number for the specified locale.
Check if a variable contains a valid number for the specified locale.
Parameters
- $value
- The string value to check
- $locale
- The locale to use. If empty we'll use the default locale set in \Punic\Data
Returns
boolean
|
public static
boolean
|
#
isInteger( string $value, string $locale = '' )
Check if a variable contains a valid integer number for the specified locale.
Check if a variable contains a valid integer number for the specified locale.
Parameters
- $value
- The string value to check
- $locale
- The locale to use. If empty we'll use the default locale set in \Punic\Data
Returns
boolean
|
public static
string
|
#
format( integer|float|string $value, integer|null $precision = null, string $locale = '' )
Localize a number representation (for instance, converts 1234.5 to '1,234.5' in case of English and to '1.234,5' in case of Italian).
Localize a number representation (for instance, converts 1234.5 to '1,234.5' in case of English and to '1.234,5' in case of Italian).
Parameters
- $value
- The string value to convert
- $precision
- The wanted precision (well use http://php.net/manual/function.round.php)
- $locale
- The locale to use. If empty we'll use the default locale set in \Punic\Data
Returns
string Returns an empty string $value is not a number, otherwise returns the localized representation of the number
|
public static
string
|
#
formatPercent( integer|float|string $value, integer|null $precision = null, string $locale = '' )
Localize a percentage (for instance, converts 12.345 to '1,234.5%' in case of English and to '1.234,5 %' in case of Danish).
Localize a percentage (for instance, converts 12.345 to '1,234.5%' in case of English and to '1.234,5 %' in case of Danish).
Parameters
- $value
- The string value to convert
- $precision
- The wanted precision (well use http://php.net/manual/function.round.php)
- $locale
- The locale to use. If empty we'll use the default locale set in \Punic\Data
Returns
string Returns an empty string $value is not a number, otherwise returns the localized representation of the percentage
|
public static
string
|
#
formatCurrency( integer|float|string $value, string $currencyCode, string $kind = 'standard', integer|null $precision = null, string $which = '', string $locale = '' )
Localize a currency amount (for instance, converts 12.345 to '1,234.5%' in case of English and to '1.234,5 %' in case of Danish).
Localize a currency amount (for instance, converts 12.345 to '1,234.5%' in case of English and to '1.234,5 %' in case of Danish).
Parameters
- $value
- The string value to convert
- $currencyCode
- The 3-letter currency code
- $kind
- The currency variant, either "standard" or "accounting"
- $precision
- The wanted precision (well use http://php.net/manual/function.round.php)
- $which
- The currency symbol to use, "" for default, "long" for the currency name, "narrow", "alt" for alternative, or "code" for the 3-letter currency code
- $locale
- The locale to use. If empty we'll use the default locale set in \Punic\Data
Returns
string Returns an empty string $value is not a number, otherwise returns the localized representation of the amount
|
public static
integer|float|null
|
#
unformat( string $value, string $locale = '' )
Convert a localized representation of a number to a number (for instance, converts the string '1,234' to 1234 in case of English and to 1.234 in case of Italian).
Convert a localized representation of a number to a number (for instance, converts the string '1,234' to 1234 in case of English and to 1.234 in case of Italian).
Parameters
- $value
- The string value to convert
- $locale
- The locale to use. If empty we'll use the default locale set in \Punic\Data
Returns
integer|float|null Returns null if $value is not valid, the numeric value otherwise
|
public static
string
|
#
spellOut( integer|float|string $value, string $type, string $locale )
Spell out a number (e.g. "one hundred twenty-three" or "twenty-third") or convert to a different numbering system, e.g Roman numerals.
Spell out a number (e.g. "one hundred twenty-three" or "twenty-third") or convert to a different numbering system, e.g Roman numerals.
Some types are language-dependent and reflect e.g. gender and case. Refer to the CLDR XML source for supported types.
Available numbering systems are specified in the "root" locale.
Parameters
- $value
- The value to localize/spell out
- $type
- The format type, e.g. "spellout-numbering", "spellout-numbering-year", "spellout-cardinal", "digits-ordinal", "roman-upper".
- $locale
- The locale to use. If empty we'll use the default locale set in \Punic\Data
Returns
string The spelled number
See
https://www.unicode.org/repos/cldr/trunk/common/rbnf/
https://www.unicode.org/repos/cldr/trunk/common/rbnf/root.xml
|