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
__construct(string $locale = 'en', int $style = null, string $pattern = null) Constructor. | ||
static NumberFormatter | create(string $locale = 'en', int $style = null, string $pattern = null) Static constructor. | |
string | formatCurrency(float $value, string $currency) Format a currency value. | |
bool|string | format(number $value, int $type = self::TYPE_DEFAULT) Format a number. | |
bool|int | getAttribute(int $attr) Returns an attribute value. | |
int | getErrorCode() Returns formatter's last error code. Always returns the UZEROERROR class constant value. | |
string | getErrorMessage() Returns formatter's last error message. Always returns the UZEROERROR_MESSAGE class constant value. | |
string | getLocale(int $type = Locale::ACTUAL_LOCALE) Returns the formatter's locale. | |
bool|string | getPattern() Not supported. Returns the formatter's pattern. | |
bool|string | getSymbol(int $attr) Not supported. Returns a formatter symbol value. | |
bool|string | getTextAttribute(int $attr) Not supported. Returns a formatter text attribute value. | |
bool|string | parseCurrency(string $value, string $currency, int $position = null) Not supported. Parse a currency number. | |
int|float|false | parse(string $value, int $type = self::TYPE_DOUBLE, int $position) Parse a number. | |
bool | setAttribute(int $attr, int $value) Set an attribute. | |
bool | setPattern(string $pattern) Not supported. Set the formatter's pattern. | |
bool | setSymbol(int $attr, string $value) Not supported. Set the formatter's symbol. | |
bool | setTextAttribute(int $attr, int $value) Not supported. Set a text attribute. |
Details
__construct(string $locale = 'en', int $style = null, string $pattern = null)
Constructor.
static NumberFormatter create(string $locale = 'en', int $style = null, string $pattern = null)
Static constructor.
string formatCurrency(float $value, string $currency)
Format a currency value.
bool|string format(number $value, int $type = self::TYPE_DEFAULT)
Format a number.
bool|int getAttribute(int $attr)
Returns an attribute value.
int getErrorCode()
Returns formatter's last error code. Always returns the UZEROERROR class constant value.
string getErrorMessage()
Returns formatter's last error message. Always returns the UZEROERROR_MESSAGE class constant value.
string getLocale(int $type = Locale::ACTUAL_LOCALE)
Returns the formatter's locale.
The parameter $type is currently ignored.
bool|string getPattern()
Not supported. Returns the formatter's pattern.
bool|string getSymbol(int $attr)
Not supported. Returns a formatter symbol value.
bool|string getTextAttribute(int $attr)
Not supported. Returns a formatter text attribute value.
bool|string parseCurrency(string $value, string $currency, int $position = null)
Not supported. Parse a currency number.
int|float|false parse(string $value, int $type = self::TYPE_DOUBLE, int $position)
Parse a number.
bool setAttribute(int $attr, int $value)
Set an attribute.
bool setPattern(string $pattern)
Not supported. Set the formatter's pattern.
bool setSymbol(int $attr, string $value)
Not supported. Set the formatter's symbol.
bool setTextAttribute(int $attr, int $value)
Not supported. Set a text attribute.
Please login to continue.