NumberFormatter
class NumberFormatter
Replacement for PHP's native {@link \NumberFormatter} class.
The only methods currently supported in this class are:
- {@link __construct}
- {@link create}
- {@link formatCurrency}
- {@link format}
- {@link getAttribute}
- {@link getErrorCode}
- {@link getErrorMessage}
- {@link getLocale}
- {@link parse}
- {@link setAttribute}
Constants
PATTERN_DECIMAL |
|
DECIMAL |
|
CURRENCY |
|
PERCENT |
|
SCIENTIFIC |
|
SPELLOUT |
|
ORDINAL |
|
DURATION |
|
PATTERN_RULEBASED |
|
IGNORE |
|
DEFAULT_STYLE |
|
TYPE_DEFAULT |
|
TYPE_INT32 |
|
TYPE_INT64 |
|
TYPE_DOUBLE |
|
TYPE_CURRENCY |
|
PARSE_INT_ONLY |
|
GROUPING_USED |
|
DECIMAL_ALWAYS_SHOWN |
|
MAX_INTEGER_DIGITS |
|
MIN_INTEGER_DIGITS |
|
INTEGER_DIGITS |
|
MAX_FRACTION_DIGITS |
|
MIN_FRACTION_DIGITS |
|
FRACTION_DIGITS |
|
MULTIPLIER |
|
GROUPING_SIZE |
|
ROUNDING_MODE |
|
ROUNDING_INCREMENT |
|
FORMAT_WIDTH |
|
PADDING_POSITION |
|
SECONDARY_GROUPING_SIZE |
|
SIGNIFICANT_DIGITS_USED |
|
MIN_SIGNIFICANT_DIGITS |
|
MAX_SIGNIFICANT_DIGITS |
|
LENIENT_PARSE |
|
POSITIVE_PREFIX |
|
POSITIVE_SUFFIX |
|
NEGATIVE_PREFIX |
|
NEGATIVE_SUFFIX |
|
PADDING_CHARACTER |
|
CURRENCY_CODE |
|
DEFAULT_RULESET |
|
PUBLIC_RULESETS |
|
DECIMAL_SEPARATOR_SYMBOL |
|
GROUPING_SEPARATOR_SYMBOL |
|
PATTERN_SEPARATOR_SYMBOL |
|
PERCENT_SYMBOL |
|
ZERO_DIGIT_SYMBOL |
|
DIGIT_SYMBOL |
|
MINUS_SIGN_SYMBOL |
|
PLUS_SIGN_SYMBOL |
|
CURRENCY_SYMBOL |
|
INTL_CURRENCY_SYMBOL |
|
MONETARY_SEPARATOR_SYMBOL |
|
EXPONENTIAL_SYMBOL |
|
PERMILL_SYMBOL |
|
PAD_ESCAPE_SYMBOL |
|
INFINITY_SYMBOL |
|
NAN_SYMBOL |
|
SIGNIFICANT_DIGIT_SYMBOL |
|
MONETARY_GROUPING_SEPARATOR_SYMBOL |
|
ROUND_CEILING |
|
ROUND_FLOOR |
|
ROUND_DOWN |
|
ROUND_UP |
|
ROUND_HALFEVEN |
|
ROUND_HALFDOWN |
|
ROUND_HALFUP |
|
PAD_BEFORE_PREFIX |
|
PAD_AFTER_PREFIX |
|
PAD_BEFORE_SUFFIX |
|
PAD_AFTER_SUFFIX |
|
Methods
Constructor.
Static constructor.
Format a currency value.
Format a number.
Returns an attribute value.
Returns formatter's last error code. Always returns the UZEROERROR class constant value.
Returns formatter's last error message. Always returns the UZEROERROR_MESSAGE class constant value.
Returns the formatter's locale.
Not supported. Returns the formatter's pattern.
Not supported. Returns a formatter symbol value.
Not supported. Returns a formatter text attribute value.
Not supported. Parse a currency number.
Parse a number.
Set an attribute.
Not supported. Set the formatter's pattern.
Not supported. Set the formatter's symbol.
Not supported. Set a text attribute.
Details
at line line 284
__construct(string $locale = 'en', int $style = null, string $pattern = null)
Constructor.
at line line 323
static NumberFormatter
create(string $locale = 'en', int $style = null, string $pattern = null)
Static constructor.
at line line 339
string
formatCurrency(float $value, string $currency)
Format a currency value.
at line line 377
bool|string
format(number $value, int $type = self::TYPE_DEFAULT)
Format a number.
at line line 418
bool|int
getAttribute(int $attr)
Returns an attribute value.
at line line 430
int
getErrorCode()
Returns formatter's last error code. Always returns the UZEROERROR class constant value.
at line line 442
string
getErrorMessage()
Returns formatter's last error message. Always returns the UZEROERROR_MESSAGE class constant value.
at line line 459
string
getLocale(int $type = Locale::ACTUAL_LOCALE)
Returns the formatter's locale.
The parameter $type is currently ignored.
at line line 473
bool|string
getPattern()
Not supported. Returns the formatter's pattern.
at line line 487
bool|string
getSymbol(int $attr)
Not supported. Returns a formatter symbol value.
at line line 501
bool|string
getTextAttribute(int $attr)
Not supported. Returns a formatter text attribute value.
at line line 519
bool|string
parseCurrency(string $value, string $currency, int $position = null)
Not supported. Parse a currency number.
at line line 535
bool|string
parse(string $value, int $type = self::TYPE_DOUBLE, int $position)
Parse a number.
at line line 589
bool
setAttribute(int $attr, int $value)
Set an attribute.
at line line 635
bool
setPattern(string $pattern)
Not supported. Set the formatter's pattern.
at line line 652
bool
setSymbol(int $attr, string $value)
Not supported. Set the formatter's symbol.
at line line 669
bool
setTextAttribute(int $attr, int $value)
Not supported. Set a text attribute.