W3cubDocs

/Symfony 2.7

Symfony\Component\Locale\Stub\StubNumberFormatter

class StubNumberFormatter extends NumberFormatter

Alias of {@link \Symfony\Component\Intl\NumberFormatter\NumberFormatter}.

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.

from NumberFormatter
static NumberFormatter create(string $locale = 'en', int $style = null, string $pattern = null)

Static constructor.

from NumberFormatter
string formatCurrency(float $value, string $currency)

Format a currency value

from NumberFormatter
Boolean|string format(number $value, int $type = self::TYPE_DEFAULT)

Format a number

from NumberFormatter
Boolean|int getAttribute(int $attr)

Returns an attribute value

from NumberFormatter
int getErrorCode()

Returns formatter's last error code.

from NumberFormatter
string getErrorMessage()

Returns formatter's last error message.

from NumberFormatter
string getLocale(int $type = Locale::ACTUAL_LOCALE)

Returns the formatter's locale

from NumberFormatter
Boolean|string getPattern()

Not supported.

from NumberFormatter
Boolean|string getSymbol(int $attr)

Not supported.

from NumberFormatter
Boolean|string getTextAttribute(int $attr)

Not supported.

from NumberFormatter
Boolean|string parseCurrency(string $value, string $currency, int $position = null)

Not supported.

from NumberFormatter
Boolean|string parse(string $value, string $type = self::TYPE_DOUBLE, int $position)

Parse a number

from NumberFormatter
Boolean setAttribute(int $attr, int $value)

Set an attribute

from NumberFormatter
Boolean setPattern(string $pattern)

Not supported.

from NumberFormatter
Boolean setSymbol(int $attr, string $value)

Not supported.

from NumberFormatter
Boolean setTextAttribute(int $attr, int $value)

Not supported.

from NumberFormatter

Details

public __construct(string $locale = 'en', int $style = null, string $pattern = null)

Constructor.

Parameters

string $locale The locale code. The only currently supported locale is "en".
int $style Style of the formatting, one of the format style constants. The only supported styles are NumberFormatter::DECIMAL and NumberFormatter::CURRENCY.
string $pattern Not supported. A pattern string in case $style is NumberFormat::PATTERNDECIMAL or NumberFormat::PATTERNRULEBASED. It must conform to the syntax described in the ICU DecimalFormat or ICU RuleBasedNumberFormat documentation

Exceptions

MethodArgumentValueNotImplementedException When $locale different than "en" is passed
MethodArgumentValueNotImplementedException When the $style is not supported
MethodArgumentNotImplementedException When the pattern value is different than null

See also

http://www.php.net/manual/en/numberformatter.create.php
http://www.icu-project.org/apiref/icu4c/classDecimalFormat.html#_details
http://www.icu-project.org/apiref/icu4c/classRuleBasedNumberFormat.html#_details

static public NumberFormatter create(string $locale = 'en', int $style = null, string $pattern = null)

Static constructor.

Parameters

string $locale The locale code. The only supported locale is "en".
int $style Style of the formatting, one of the format style constants. The only currently supported styles are NumberFormatter::DECIMAL and NumberFormatter::CURRENCY.
string $pattern Not supported. A pattern string in case $style is NumberFormat::PATTERNDECIMAL or NumberFormat::PATTERNRULEBASED. It must conform to the syntax described in the ICU DecimalFormat or ICU RuleBasedNumberFormat documentation

Return Value

NumberFormatter

Exceptions

MethodArgumentValueNotImplementedException When $locale different than "en" is passed
MethodArgumentValueNotImplementedException When the $style is not supported
MethodArgumentNotImplementedException When the pattern value is different than null

See also

http://www.php.net/manual/en/numberformatter.create.php
http://www.icu-project.org/apiref/icu4c/classDecimalFormat.html#_details
http://www.icu-project.org/apiref/icu4c/classRuleBasedNumberFormat.html#_details

public string formatCurrency(float $value, string $currency)

Format a currency value

Parameters

float $value The numeric currency value
string $currency The 3-letter ISO 4217 currency code indicating the currency to use

Return Value

string The formatted currency value

See also

http://www.php.net/manual/en/numberformatter.formatcurrency.php
http://www.iso.org/iso/support/faqs/faqs_widely_used_standards/widely_used_standards_other/currency_codes/currency_codes_list-1.htm

public Boolean|string format(number $value, int $type = self::TYPE_DEFAULT)

Format a number

Parameters

number $value The value to format
int $type Type of the formatting, one of the format type constants. Only type NumberFormatter::TYPE_DEFAULT is currently supported.

Return Value

Boolean|string The formatted value or false on error

Exceptions

NotImplementedException If the method is called with the class $style 'CURRENCY'
MethodArgumentValueNotImplementedException If the $type is different than TYPE_DEFAULT

See also

http://www.php.net/manual/en/numberformatter.format.php

public Boolean|int getAttribute(int $attr)

Returns an attribute value

Parameters

int $attr An attribute specifier, one of the numeric attribute constants

Return Value

Boolean|int The attribute value on success or false on error

See also

http://www.php.net/manual/en/numberformatter.getattribute.php

public int getErrorCode()

Returns formatter's last error code.

Always returns the UZEROERROR class constant value

Return Value

int The error code from last formatter call

See also

http://www.php.net/manual/en/numberformatter.geterrorcode.php

public string getErrorMessage()

Returns formatter's last error message.

Always returns the UZEROERROR_MESSAGE class constant value

Return Value

string The error message from last formatter call

See also

http://www.php.net/manual/en/numberformatter.geterrormessage.php

public string getLocale(int $type = Locale::ACTUAL_LOCALE)

Returns the formatter's locale

The parameter $type is currently ignored.

Parameters

int $type Not supported. The locale name type to return (Locale::VALIDLOCALE or Locale::ACTUALLOCALE)

Return Value

string The locale used to create the formatter. Currently always returns "en".

See also

http://www.php.net/manual/en/numberformatter.getlocale.php

public Boolean|string getPattern()

Not supported.

Returns the formatter's pattern

Return Value

Boolean|string The pattern string used by the formatter or false on error

Exceptions

MethodNotImplementedException

See also

http://www.php.net/manual/en/numberformatter.getpattern.php

public Boolean|string getSymbol(int $attr)

Not supported.

Returns a formatter symbol value

Parameters

int $attr A symbol specifier, one of the format symbol constants

Return Value

Boolean|string The symbol value or false on error

See also

http://www.php.net/manual/en/numberformatter.getsymbol.php

public Boolean|string getTextAttribute(int $attr)

Not supported.

Returns a formatter text attribute value

Parameters

int $attr An attribute specifier, one of the text attribute constants

Return Value

Boolean|string The attribute value or false on error

See also

http://www.php.net/manual/en/numberformatter.gettextattribute.php

public Boolean|string parseCurrency(string $value, string $currency, int $position = null)

Not supported.

Parse a currency number

Parameters

string $value The value to parse
string $currency Parameter to receive the currency name (reference)
int $position Offset to begin the parsing on return this value will hold the offset at which the parsing ended

Return Value

Boolean|string The parsed numeric value of false on error

Exceptions

MethodNotImplementedException

See also

http://www.php.net/manual/en/numberformatter.parsecurrency.php

public Boolean|string parse(string $value, string $type = self::TYPE_DOUBLE, int $position)

Parse a number

Parameters

string $value The value to parse
string $type Type of the formatting, one of the format type constants. NumberFormatter::TYPE_DOUBLE by default
int $position Offset to begin the parsing on return this value will hold the offset at which the parsing ended

Return Value

Boolean|string The parsed value of false on error

See also

http://www.php.net/manual/en/numberformatter.parse.php

public Boolean setAttribute(int $attr, int $value)

Set an attribute

Parameters

int $attr An attribute specifier, one of the numeric attribute constants. The only currently supported attributes are NumberFormatter::FRACTIONDIGITS, NumberFormatter::GROUPINGUSED and NumberFormatter::ROUNDING_MODE.
int $value The attribute value. The only currently supported rounding modes are NumberFormatter::ROUNDHALFEVEN, NumberFormatter::ROUNDHALFDOWN and NumberFormatter::ROUND_HALFUP.

Return Value

Boolean true on success or false on failure

Exceptions

MethodArgumentValueNotImplementedException When the $attr is not supported
MethodArgumentValueNotImplementedException When the $value is not supported

See also

http://www.php.net/manual/en/numberformatter.setattribute.php

public Boolean setPattern(string $pattern)

Not supported.

Set the formatter's pattern

Parameters

string $pattern A pattern string in conformance with the ICU DecimalFormat documentation

Return Value

Boolean true on success or false on failure

Exceptions

MethodNotImplementedException

See also

http://www.php.net/manual/en/numberformatter.setpattern.php
http://www.icu-project.org/apiref/icu4c/classDecimalFormat.html#_details

public Boolean setSymbol(int $attr, string $value)

Not supported.

Set the formatter's symbol

Parameters

int $attr A symbol specifier, one of the format symbol constants
string $value The value for the symbol

Return Value

Boolean true on success or false on failure

Exceptions

MethodNotImplementedException

See also

http://www.php.net/manual/en/numberformatter.setsymbol.php

public Boolean setTextAttribute(int $attr, int $value)

Not supported.

Set a text attribute

Parameters

int $attr An attribute specifier, one of the text attribute constants
int $value The attribute value

Return Value

Boolean true on success or false on failure

Exceptions

MethodNotImplementedException

See also

http://www.php.net/manual/en/numberformatter.settextattribute.php

© 2004–2016 Fabien Potencier
Licensed under the MIT License.
http://api.symfony.com/2.7/Symfony/Component/Locale/Stub/StubNumberFormatter.html