PHP Class CommerceGuys\Intl\Formatter\NumberFormatter

Inheritance: implements CommerceGuys\Intl\Formatter\NumberFormatterInterface
Show file Open project: commerceguys/intl Class Usage Examples

Protected Properties

Property Type Description
$currencyDisplay integer The currency display style.
$digits array Localized digits.
$groupingUsed boolean Whether grouping is used.
$maximumFractionDigits integer The maximum number of fraction digits to show.
$minimumFractionDigits integer The minimum number of fraction digits to show.
$negativePattern string The number pattern used to format negative numbers.
$numberFormat CommerceGuys\Intl\NumberFormat\NumberFormatInterface The number format.
$positivePattern string The number pattern used to format positive numbers.
$primaryGroupSize integer The size of the group of digits closest to the decimal point.
$secondaryGroupSize integer The size of every group of digits after the primary group.

Public Methods

Method Description
__construct ( CommerceGuys\Intl\NumberFormat\NumberFormatInterface $numberFormat, integer $style = self::DECIMAL ) Creaes a NumberFormatter instance.
format ( $value )
formatCurrency ( $value, CommerceGuys\Intl\Currency\CurrencyInterface $currency )
getCurrencyDisplay ( )
getMaximumFractionDigits ( )
getMinimumFractionDigits ( )
getNumberFormat ( )
isGroupingUsed ( )
parseCurrency ( $value, CommerceGuys\Intl\Currency\CurrencyInterface $currency )
setCurrencyDisplay ( $currencyDisplay )
setGroupingUsed ( $groupingUsed )
setMaximumFractionDigits ( $maximumFractionDigits )
setMinimumFractionDigits ( $minimumFractionDigits )

Protected Methods

Method Description
replaceDigits ( string $value ) : string Replaces digits with their localized equivalents.
replaceSymbols ( string $value ) : string Replaces number symbols with their localized equivalents.

Method Details

__construct() public method

Creaes a NumberFormatter instance.
public __construct ( CommerceGuys\Intl\NumberFormat\NumberFormatInterface $numberFormat, integer $style = self::DECIMAL )
$numberFormat CommerceGuys\Intl\NumberFormat\NumberFormatInterface The number format.
$style integer The formatting style.

format() public method

public format ( $value )

formatCurrency() public method

public formatCurrency ( $value, CommerceGuys\Intl\Currency\CurrencyInterface $currency )
$currency CommerceGuys\Intl\Currency\CurrencyInterface

getCurrencyDisplay() public method

public getCurrencyDisplay ( )

getMaximumFractionDigits() public method

getMinimumFractionDigits() public method

getNumberFormat() public method

public getNumberFormat ( )

isGroupingUsed() public method

public isGroupingUsed ( )

parseCurrency() public method

public parseCurrency ( $value, CommerceGuys\Intl\Currency\CurrencyInterface $currency )
$currency CommerceGuys\Intl\Currency\CurrencyInterface

replaceDigits() protected method

Replaces digits with their localized equivalents.
protected replaceDigits ( string $value ) : string
$value string The value being formatted.
return string

replaceSymbols() protected method

Replaces number symbols with their localized equivalents.
See also: http://cldr.unicode.org/translation/number-symbols
protected replaceSymbols ( string $value ) : string
$value string The value being formatted.
return string

setCurrencyDisplay() public method

public setCurrencyDisplay ( $currencyDisplay )

setGroupingUsed() public method

public setGroupingUsed ( $groupingUsed )

setMaximumFractionDigits() public method

public setMaximumFractionDigits ( $maximumFractionDigits )

setMinimumFractionDigits() public method

public setMinimumFractionDigits ( $minimumFractionDigits )

Property Details

$currencyDisplay protected property

The currency display style.
protected int $currencyDisplay
return integer

$digits protected property

Localized digits.
protected array $digits
return array

$groupingUsed protected property

Whether grouping is used.
protected bool $groupingUsed
return boolean

$maximumFractionDigits protected property

The maximum number of fraction digits to show.
protected int $maximumFractionDigits
return integer

$minimumFractionDigits protected property

The minimum number of fraction digits to show.
protected int $minimumFractionDigits
return integer

$negativePattern protected property

The number pattern used to format negative numbers.
protected string $negativePattern
return string

$numberFormat protected property

The number format.
protected NumberFormatInterface,CommerceGuys\Intl\NumberFormat $numberFormat
return CommerceGuys\Intl\NumberFormat\NumberFormatInterface

$positivePattern protected property

The number pattern used to format positive numbers.
protected string $positivePattern
return string

$primaryGroupSize protected property

The size of the group of digits closest to the decimal point.
protected int $primaryGroupSize
return integer

$secondaryGroupSize protected property

The size of every group of digits after the primary group.
protected int $secondaryGroupSize
return integer