PHP Class Neos\Flow\I18n\Formatter\NumberFormatter

Inheritance: implements Neos\Flow\I18n\Formatter\FormatterInterface
Afficher le fichier Open project: neos/flow-development-collection Class Usage Examples

Protected Properties

Свойство Type Description
$numbersReader Neos\Flow\I18n\Cldr\Reader\NumbersReader

Méthodes publiques

Méthode Description
format ( mixed $value, Locale $locale, array $styleProperties = [] ) : string Formats provided value using optional style properties
formatCurrencyNumber ( mixed $number, Locale $locale, string $currency, string $formatLength = NumbersReader::FORMAT_LENGTH_DEFAULT ) : string Formats number with format string for currency defined in CLDR for particular locale.
formatDecimalNumber ( mixed $number, Locale $locale, string $formatLength = NumbersReader::FORMAT_LENGTH_DEFAULT ) : string Formats number with format string for decimal numbers defined in CLDR for particular locale.
formatNumberWithCustomPattern ( mixed $number, string $format, Locale $locale ) : string Returns number formatted by custom format, string provided in parameter.
formatPercentNumber ( mixed $number, Locale $locale, string $formatLength = NumbersReader::FORMAT_LENGTH_DEFAULT ) : string Formats number with format string for percentage defined in CLDR for particular locale.
injectNumbersReader ( NumbersReader $numbersReader ) : void

Méthodes protégées

Méthode Description
doFormattingWithParsedFormat ( mixed $number, array $parsedFormat, array $symbols, string $currency = null ) : string Formats provided float or integer.

Method Details

doFormattingWithParsedFormat() protected méthode

Format rules defined in $parsedFormat array are used. Localizable symbols are replaced with elements from $symbols array, and currency placeholder is replaced with the value of $currency, if not NULL. If $number is NaN or infinite, proper localized symbol will be returned, as defined in CLDR specification.
protected doFormattingWithParsedFormat ( mixed $number, array $parsedFormat, array $symbols, string $currency = null ) : string
$number mixed Float or int, can be negative, can be NaN or infinite
$parsedFormat array An array describing format (as in $parsedFormats property)
$symbols array An array with symbols to use (as in $localeSymbols property)
$currency string Currency symbol to be inserted into formatted number (if applicable)
Résultat string Formatted number. Will return string-casted version of $number if pattern is FALSE

format() public méthode

Formats provided value using optional style properties
public format ( mixed $value, Locale $locale, array $styleProperties = [] ) : string
$value mixed Formatter-specific variable to format (can be integer, \DateTime, etc)
$locale Neos\Flow\I18n\Locale Locale to use
$styleProperties array Integer-indexed array of formatter-specific style properties (can be empty)
Résultat string String representation of $value provided, or (string)$value

formatCurrencyNumber() public méthode

Currency symbol provided will be inserted into formatted number string. Note: currently length is not used in currencyFormats from CLDR. But it's defined in the specification, so we support it here.
public formatCurrencyNumber ( mixed $number, Locale $locale, string $currency, string $formatLength = NumbersReader::FORMAT_LENGTH_DEFAULT ) : string
$number mixed Float or int, can be negative, can be NaN or infinite
$locale Neos\Flow\I18n\Locale
$currency string Currency symbol (or name)
$formatLength string One of NumbersReader FORMAT_LENGTH constants
Résultat string Formatted number. Will return string-casted version of $number if there is no pattern for given $locale / $formatLength

formatDecimalNumber() public méthode

Note: currently length is not used in decimalFormats from CLDR. But it's defined in the specification, so we support it here.
public formatDecimalNumber ( mixed $number, Locale $locale, string $formatLength = NumbersReader::FORMAT_LENGTH_DEFAULT ) : string
$number mixed Float or int, can be negative, can be NaN or infinite
$locale Neos\Flow\I18n\Locale
$formatLength string One of NumbersReader FORMAT_LENGTH constants
Résultat string Formatted number. Will return string-casted version of $number if there is no pattern for given $locale / $formatLength

formatNumberWithCustomPattern() public méthode

Format must obey syntax defined in CLDR specification, excluding unimplemented features (see documentation for this class). Format is remembered in this classes cache and won't be parsed again for some time.
public formatNumberWithCustomPattern ( mixed $number, string $format, Locale $locale ) : string
$number mixed Float or int, can be negative, can be NaN or infinite
$format string Format string
$locale Neos\Flow\I18n\Locale A locale used for finding symbols array
Résultat string Formatted number. Will return string-casted version of $number if pattern is not valid / supported

formatPercentNumber() public méthode

Note: currently length is not used in percentFormats from CLDR. But it's defined in the specification, so we support it here.
public formatPercentNumber ( mixed $number, Locale $locale, string $formatLength = NumbersReader::FORMAT_LENGTH_DEFAULT ) : string
$number mixed Float or int, can be negative, can be NaN or infinite
$locale Neos\Flow\I18n\Locale
$formatLength string One of NumbersReader FORMAT_LENGTH constants
Résultat string Formatted number. Will return string-casted version of $number if there is no pattern for given $locale / $formatLength

injectNumbersReader() public méthode

public injectNumbersReader ( NumbersReader $numbersReader ) : void
$numbersReader Neos\Flow\I18n\Cldr\Reader\NumbersReader
Résultat void

Property Details

$numbersReader protected_oe property

protected NumbersReader,Neos\Flow\I18n\Cldr\Reader $numbersReader
Résultat Neos\Flow\I18n\Cldr\Reader\NumbersReader