mediatekformation

MoneyToLocalizedStringTransformer extends NumberToLocalizedStringTransformer
in package

Transforms between a normalized format and a localized money string.

Tags
author

Bernhard Schussek bschussek@gmail.com

author

Florian Eckerstorfer florian@eckerstorfer.org

Table of Contents

ROUND_CEILING  = \NumberFormatter::ROUND_CEILING
Rounds a number towards positive infinity.
ROUND_DOWN  = \NumberFormatter::ROUND_DOWN
Rounds a number towards zero.
ROUND_FLOOR  = \NumberFormatter::ROUND_FLOOR
Rounds a number towards negative infinity.
ROUND_HALF_DOWN  = \NumberFormatter::ROUND_HALFDOWN
Rounds to the nearest number and halves towards zero.
ROUND_HALF_EVEN  = \NumberFormatter::ROUND_HALFEVEN
Rounds to the nearest number and halves to the next even number.
ROUND_HALF_UP  = \NumberFormatter::ROUND_HALFUP
Rounds to the nearest number and halves away from zero.
ROUND_UP  = \NumberFormatter::ROUND_UP
Rounds a number away from zero.
$grouping  : mixed
$roundingMode  : mixed
$divisor  : mixed
$locale  : mixed
$scale  : mixed
__construct()  : mixed
reverseTransform()  : int|float|null
Transforms a localized money string into a normalized format.
transform()  : string
Transforms a normalized format into a localized money string.
getNumberFormatter()  : NumberFormatter
Returns a preconfigured \NumberFormatter instance.
round()  : int|float
Rounds a number according to the configured scale and rounding mode.

Constants

ROUND_CEILING

Rounds a number towards positive infinity.

public mixed ROUND_CEILING = \NumberFormatter::ROUND_CEILING

Rounds 1.4 to 2 and -1.4 to -1.

ROUND_HALF_DOWN

Rounds to the nearest number and halves towards zero.

public mixed ROUND_HALF_DOWN = \NumberFormatter::ROUND_HALFDOWN

Rounds 2.5 and 1.6 to 2, 1.5 and 1.4 to 1.

ROUND_HALF_EVEN

Rounds to the nearest number and halves to the next even number.

public mixed ROUND_HALF_EVEN = \NumberFormatter::ROUND_HALFEVEN

Rounds 2.5, 1.6 and 1.5 to 2 and 1.4 to 1.

ROUND_HALF_UP

Rounds to the nearest number and halves away from zero.

public mixed ROUND_HALF_UP = \NumberFormatter::ROUND_HALFUP

Rounds 2.5 to 3, 1.6 and 1.5 to 2 and 1.4 to 1.

Properties

Methods

__construct()

public __construct([int|null $scale = 2 ][, bool|null $grouping = true ][, int|null $roundingMode = self::ROUND_HALF_UP ][, int|null $divisor = 1 ]) : mixed
Parameters
$scale : int|null = 2
$grouping : bool|null = true
$roundingMode : int|null = self::ROUND_HALF_UP
$divisor : int|null = 1
Return values
mixed

reverseTransform()

Transforms a localized money string into a normalized format.

public reverseTransform(string $value) : int|float|null
Parameters
$value : string

Localized money string

Tags
throws
TransformationFailedException

if the given value is not a string or if the value can not be transformed

Return values
int|float|null

Normalized number

transform()

Transforms a normalized format into a localized money string.

public transform(int|float|null $value) : string
Parameters
$value : int|float|null

Normalized number

Tags
throws
TransformationFailedException

if the given value is not numeric or if the value can not be transformed

Return values
string

Localized money string

round()

Rounds a number according to the configured scale and rounding mode.

private round(int|float $number) : int|float
Parameters
$number : int|float

A number

Return values
int|float

The rounded number

Search results