Symfony2 API
Class

Symfony\Component\Form\Extension\Core\DataTransformer\MoneyToLocalizedStringTransformer

class MoneyToLocalizedStringTransformer extends NumberToLocalizedStringTransformer

Transforms between a normalized format and a localized money string.

Constants

ROUND_CEILING

Rounds a number towards positive infinity.

Rounds 1.4 to 2 and -1.4 to -1.

ROUND_FLOOR

Rounds a number towards negative infinity.

Rounds 1.4 to 1 and -1.4 to -2.

ROUND_UP

Rounds a number away from zero.

Rounds 1.4 to 2 and -1.4 to -2.

ROUND_DOWN

Rounds a number towards zero.

Rounds 1.4 to 1 and -1.4 to -1.

ROUND_HALF_EVEN

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

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.

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

ROUND_HALF_DOWN

Rounds to the nearest number and halves towards zero.

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

ROUND_HALFEVEN

Alias for {@link self::ROUNDHALFEVEN}.

ROUND_HALFUP

Alias for {@link self::ROUNDHALFUP}.

ROUND_HALFDOWN

Alias for {@link self::ROUNDHALFDOWN}.

Methods

__construct($precision = 2, $grouping = true, $roundingMode = self::ROUND_HALF_UP, $divisor = 1)

string transform(int|float $value)

Transforms a normalized format into a localized money string.

int|float reverseTransform(string $value)

Transforms a localized money string into a normalized format.

Details

at line 26
public __construct($precision = 2, $grouping = true, $roundingMode = self::ROUND_HALF_UP, $divisor = 1)

Parameters

$precision
$grouping
$roundingMode
$divisor

at line 55
public string transform(int|float $value)

Transforms a normalized format into a localized money string.

Parameters

int|float $value Normalized number

Return Value

string Localized money string.

Exceptions

TransformationFailedException If the given value is not numeric or if the value can not be transformed.

at line 78
public int|float reverseTransform(string $value)

Transforms a localized money string into a normalized format.

Parameters

string $value Localized money string

Return Value

int|float Normalized number

Exceptions

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