PHP Class Prado\I18N\core\NumberFormatInfo

Defines how numeric values are formatted and displayed, depending on the culture. Numeric values are formatted using standard or custom patterns stored in the properties of a NumberFormatInfo. This class contains information, such as currency, decimal separators, and other numeric symbols. To create a NumberFormatInfo for a specific culture, create a CultureInfo for that culture and retrieve the CultureInfo->NumberFormat property. Or use NumberFormatInfo::getInstance($culture). To create a NumberFormatInfo for the invariant culture, use the InvariantInfo::getInvariantInfo().
Show file Open project: pradosoft/prado Class Usage Examples

Protected Properties

Property Type Description
$pattern array The number pattern.
$properties array A list of properties that are accessable/writable.

Public Methods

Method Description
__construct ( $data = [], $type = NumberFormatInfo::DECIMAL ) Initializes a new writable instance of the NumberFormatInfo class that is dependent on the ICU data for number, decimal, and currency formatting information. N.B.You should not initialize this class directly unless you know what you are doing. Please use use NumberFormatInfo::getInstance() to create an instance.
__get ( $name ) : mixed Allow functions that begins with 'set' to be called directly as an attribute/property to retrieve the value.
__set ( $name, $value ) Allow functions that begins with 'set' to be called directly as an attribute/property to set the value.
getCurrencyInstance ( $culture = null ) : NumberFormatInfo Returns the currency format info associated with the specified culture.
getCurrencySymbol ( $currency = 'USD' ) : string Gets the string to use as the currency symbol.
getDecimalDigits ( ) : integer Indicates the number of decimal places.
getDecimalSeparator ( ) : string Gets the string to use as the decimal separator.
getDigitSize ( )
getGroupSeparator ( ) : string Gets the string that separates groups of digits to the left of the decimal in currency values.
getGroupSizes ( ) : array Gets the number of digits in each group to the left of the decimal There can be two grouping sizes, this fucntion returns array(group1, group2), if there is only 1 grouping size, group2 will be false.
getInstance ( $culture = null, $type = NumberFormatInfo::DECIMAL ) : NumberFormatInfo Returns the NumberFormatInfo associated with the specified culture.
getInvariantInfo ( $type = NumberFormatInfo::DECIMAL ) : NumberFormatInfo Gets the default NumberFormatInfo that is culture-independent (invariant).
getNaNSymbol ( ) : string Gets the string that represents the IEEE NaN (not a number) value.
getNegativeInfinitySymbol ( ) : string Gets the string that represents negative infinity.
getNegativePattern ( ) : arary Gets the format pattern for negative values.
getNegativeSign ( ) : string Gets the string that denotes that the associated number is negative.
getPattern ( )
getPerMilleSymbol ( ) : string Gets the string to use as the per mille symbol.
getPercentSymbol ( ) : string Gets the string to use as the percent symbol.
getPercentageInstance ( $culture = null ) : NumberFormatInfo Returns the percentage format info associated with the specified culture.
getPositiveInfinitySymbol ( ) : string Gets the string that represents positive infinity.
getPositivePattern ( ) : arary Gets the format pattern for positive values.
getPositiveSign ( ) : string Gets the string that denotes that the associated number is positive.
getScientificInstance ( $culture = null ) : NumberFormatInfo Returns the scientific format info associated with the specified culture.
setCurrencySymbol ( $symbol ) Set the string to use as the currency symbol.
setDecimalDigits ( $value ) Set the number of decimal places.
setDecimalSeparator ( $value ) Set the string to use as the decimal separator.
setDigitSize ( $value )
setGroupSeparator ( $value ) Set the string to use as the group separator.
setGroupSizes ( $groupSize ) Set the number of digits in each group to the left of the decimal.
setNaNSymbol ( $value ) Set the string that represents the IEEE NaN (not a number) value.
setNegativeInfinitySymbol ( $value ) Set the string that represents negative infinity.
setNegativePattern ( $pattern ) Set the format pattern for negative values.
setNegativeSign ( $value ) Set the string that denotes that the associated number is negative.
setPattern ( $type = NumberFormatInfo::DECIMAL ) Set the pattern for a specific number pattern. The validate patterns NumberFormatInfo::DECIMAL, NumberFormatInfo::CURRENCY, NumberFormatInfo::PERCENTAGE, or NumberFormatInfo::SCIENTIFIC
setPerMilleSymbol ( $value ) Set the string to use as the per mille symbol.
setPercentSymbol ( $value ) Set the string to use as the percent symbol.
setPositiveInfinitySymbol ( $value ) Set the string that represents positive infinity.
setPositivePattern ( $pattern ) Set the format pattern for positive values.
setPositiveSign ( $value ) Set the string that denotes that the associated number is positive.

Protected Methods

Method Description
getPrePostfix ( $pattern ) : array Get the prefix and postfix of a pattern.
parsePattern ( $pattern ) : array Parse the given pattern and return a list of known properties.

Method Details

__construct() public method

Initializes a new writable instance of the NumberFormatInfo class that is dependent on the ICU data for number, decimal, and currency formatting information. N.B.You should not initialize this class directly unless you know what you are doing. Please use use NumberFormatInfo::getInstance() to create an instance.
See also: getInstance()
public __construct ( $data = [], $type = NumberFormatInfo::DECIMAL )

__get() public method

Allow functions that begins with 'set' to be called directly as an attribute/property to retrieve the value.
public __get ( $name ) : mixed
return mixed

__set() public method

Allow functions that begins with 'set' to be called directly as an attribute/property to set the value.
public __set ( $name, $value )

getCurrencyInstance() public static method

Returns the currency format info associated with the specified culture.
public static getCurrencyInstance ( $culture = null ) : NumberFormatInfo
return NumberFormatInfo NumberFormatInfo for the specified culture.

getCurrencySymbol() public method

Gets the string to use as the currency symbol.
public getCurrencySymbol ( $currency = 'USD' ) : string
return string currency symbol.

getDecimalDigits() public method

Indicates the number of decimal places.
public getDecimalDigits ( ) : integer
return integer number of decimal places.

getDecimalSeparator() public method

Gets the string to use as the decimal separator.
public getDecimalSeparator ( ) : string
return string decimal separator.

getDigitSize() public method

public getDigitSize ( )

getGroupSeparator() public method

Gets the string that separates groups of digits to the left of the decimal in currency values.
public getGroupSeparator ( ) : string
return string currency group separator.

getGroupSizes() public method

Gets the number of digits in each group to the left of the decimal There can be two grouping sizes, this fucntion returns array(group1, group2), if there is only 1 grouping size, group2 will be false.
public getGroupSizes ( ) : array
return array grouping size(s).

getInstance() public static method

Returns the NumberFormatInfo associated with the specified culture.
public static getInstance ( $culture = null, $type = NumberFormatInfo::DECIMAL ) : NumberFormatInfo
return NumberFormatInfo NumberFormatInfo for the specified culture.

getInvariantInfo() public static method

Gets the default NumberFormatInfo that is culture-independent (invariant).
public static getInvariantInfo ( $type = NumberFormatInfo::DECIMAL ) : NumberFormatInfo
return NumberFormatInfo default NumberFormatInfo.

getNaNSymbol() public method

Gets the string that represents the IEEE NaN (not a number) value.
public getNaNSymbol ( ) : string
return string NaN symbol.

getNegativeInfinitySymbol() public method

Gets the string that represents negative infinity.
public getNegativeInfinitySymbol ( ) : string
return string negative infinity.

getNegativePattern() public method

The negative pattern is composed of a prefix, and postfix. This function returns array(prefix, postfix).
public getNegativePattern ( ) : arary
return arary negative pattern.

getNegativeSign() public method

Gets the string that denotes that the associated number is negative.
public getNegativeSign ( ) : string
return string negative sign.

getPattern() public method

public getPattern ( )

getPerMilleSymbol() public method

Gets the string to use as the per mille symbol.
public getPerMilleSymbol ( ) : string
return string percent symbol.

getPercentSymbol() public method

Gets the string to use as the percent symbol.
public getPercentSymbol ( ) : string
return string percent symbol.

getPercentageInstance() public static method

Returns the percentage format info associated with the specified culture.
public static getPercentageInstance ( $culture = null ) : NumberFormatInfo
return NumberFormatInfo NumberFormatInfo for the specified culture.

getPositiveInfinitySymbol() public method

Gets the string that represents positive infinity.
public getPositiveInfinitySymbol ( ) : string
return string positive infinity.

getPositivePattern() public method

The positive pattern is composed of a prefix, and postfix. This function returns array(prefix, postfix).
public getPositivePattern ( ) : arary
return arary positive pattern.

getPositiveSign() public method

Gets the string that denotes that the associated number is positive.
public getPositiveSign ( ) : string
return string positive sign.

getPrePostfix() protected method

Get the prefix and postfix of a pattern.
protected getPrePostfix ( $pattern ) : array
return array of prefix and postfix, array(prefix,postfix).

getScientificInstance() public static method

Returns the scientific format info associated with the specified culture.
public static getScientificInstance ( $culture = null ) : NumberFormatInfo
return NumberFormatInfo NumberFormatInfo for the specified culture.

parsePattern() protected method

Parse the given pattern and return a list of known properties.
protected parsePattern ( $pattern ) : array
return array list of pattern properties.

setCurrencySymbol() public method

Set the string to use as the currency symbol.
public setCurrencySymbol ( $symbol )

setDecimalDigits() public method

Set the number of decimal places.
public setDecimalDigits ( $value )

setDecimalSeparator() public method

Set the string to use as the decimal separator.
public setDecimalSeparator ( $value )

setDigitSize() public method

public setDigitSize ( $value )

setGroupSeparator() public method

Set the string to use as the group separator.
public setGroupSeparator ( $value )

setGroupSizes() public method

There can be two grouping sizes, the value should be an array(group1, group2), if there is only 1 grouping size, group2 should be false.
public setGroupSizes ( $groupSize )

setNaNSymbol() public method

Set the string that represents the IEEE NaN (not a number) value.
public setNaNSymbol ( $value )

setNegativeInfinitySymbol() public method

Set the string that represents negative infinity.
public setNegativeInfinitySymbol ( $value )

setNegativePattern() public method

The negative pattern is composed of a prefix, and postfix in the form array(prefix, postfix).
public setNegativePattern ( $pattern )

setNegativeSign() public method

Set the string that denotes that the associated number is negative.
public setNegativeSign ( $value )

setPattern() public method

Set the pattern for a specific number pattern. The validate patterns NumberFormatInfo::DECIMAL, NumberFormatInfo::CURRENCY, NumberFormatInfo::PERCENTAGE, or NumberFormatInfo::SCIENTIFIC
public setPattern ( $type = NumberFormatInfo::DECIMAL )

setPerMilleSymbol() public method

Set the string to use as the per mille symbol.
public setPerMilleSymbol ( $value )

setPercentSymbol() public method

Set the string to use as the percent symbol.
public setPercentSymbol ( $value )

setPositiveInfinitySymbol() public method

Set the string that represents positive infinity.
public setPositiveInfinitySymbol ( $value )

setPositivePattern() public method

The positive pattern is composed of a prefix, and postfix in the form array(prefix, postfix).
public setPositivePattern ( $pattern )

setPositiveSign() public method

Set the string that denotes that the associated number is positive.
public setPositiveSign ( $value )

Property Details

$pattern protected property

The number pattern.
protected array $pattern
return array

$properties protected property

A list of properties that are accessable/writable.
protected array $properties
return array