class NumberFormat extends Format (View source)

Constants

TYPE

Properties

string $decimalSymbol Character to use as the decimal marker.
int $fractionDigits How many digits to display after the decimal.
string $groupingSymbol Character to be used to group digits.
string $negativeColor Text color for negative values.
boolean $negativeParens Indicates that negative values should be surrounded by parentheses
string $pattern Format string, as a subset of the ICU pattern set.
string $prefix prefix to assign to values in the visualization.
string $suffix suffix to assign to values in the visualization.

Methods

mixed
__construct( array $config = array())

Builds the NumberFormat object with specified options

array
getValues()

Same as toArray, but without the class name as a key to being multi-dimension.

from  Format
string
toJson()

Returns a JSON string representation of the object's properties.

from  Format
decimalSymbol( string $ds)

Sets the character to use as the decimal marker. The default is a dot (.)

fractionDigits( int $fd)

A number specifying how many digits to display after the decimal.

groupingSymbol( string $gs)

A character to be used to group digits to the left of the decimal into sets of three.

negativeColor( string $nc)

The text color for negative values. No default value.

negativeParens( boolean $np)

Sets whether negative values should be surrounded by parentheses.

pattern( string $p)

A format string. When provided, all other options are ignored, except negativeColor.

prefix( string $p)

Sets the string prefix for the value.

suffix( string $s)

Sets the string suffix for the value.

Details

at line 91
mixed __construct( array $config = array())

Builds the NumberFormat object with specified options

Parameters

array $config Array of options.

Return Value

mixed

Exceptions

InvalidConfigValue
InvalidConfigProperty

in Format at line 79
array getValues()

Same as toArray, but without the class name as a key to being multi-dimension.

Return Value

array Array of the options of the object.

in Format at line 97
string toJson()

Returns a JSON string representation of the object's properties.

Return Value

string

at line 103
NumberFormat decimalSymbol( string $ds)

Sets the character to use as the decimal marker. The default is a dot (.)

Parameters

string $ds

Return Value

NumberFormat

Exceptions

InvalidConfigValue

at line 127
NumberFormat fractionDigits( int $fd)

A number specifying how many digits to display after the decimal.

The default is 2. If you specify more digits than the number contains, it will display zeros for the smaller values. Truncated values will be rounded (5 rounded up).

Parameters

int $fd

Return Value

NumberFormat

Exceptions

InvalidConfigValue

at line 149
NumberFormat groupingSymbol( string $gs)

A character to be used to group digits to the left of the decimal into sets of three.

Default is a comma (,)

Parameters

string $gs

Return Value

NumberFormat

Exceptions

InvalidConfigValue

at line 171
NumberFormat negativeColor( string $nc)

The text color for negative values. No default value.

Values can be any acceptable HTML color value, such as "red" or "#FF0000".

Parameters

string $nc Valid HTML color

Return Value

NumberFormat

Exceptions

InvalidConfigValue

at line 193
NumberFormat negativeParens( boolean $np)

Sets whether negative values should be surrounded by parentheses.

Default is true.

Parameters

boolean $np

Return Value

NumberFormat

Exceptions

InvalidConfigValue

at line 219
NumberFormat pattern( string $p)

A format string. When provided, all other options are ignored, except negativeColor.

The format string is a subset of the ICU pattern set. For instance, {pattern:'#,###%'} will result in output values "1,000%", "750%", and "50%" for values 10, 7.5, and 0.5.

Parameters

string $p

Return Value

NumberFormat

Exceptions

InvalidConfigValue

See also

http://icu-project.org/apiref/icu4c/classDecimalFormat.html#_details

at line 240
NumberFormat prefix( string $p)

Sets the string prefix for the value.

Parameters

string $p

Return Value

NumberFormat

Exceptions

InvalidConfigValue

at line 261
NumberFormat suffix( string $s)

Sets the string suffix for the value.

Parameters

string $s

Return Value

NumberFormat

Exceptions

InvalidConfigValue