W3cubDocs

/Symfony 4.1

PercentToLocalizedStringTransformer

class PercentToLocalizedStringTransformer implements DataTransformerInterface

Transforms between a normalized format (integer or float) and a percentage value.

Constants

FRACTIONAL
INTEGER

Properties

static protected $types

Methods

__construct(int $scale = null, string $type = null)
mixed transform(mixed $value)

Transforms between a normalized format (integer or float) into a percentage value.

mixed reverseTransform(mixed $value)

Transforms between a percentage value into a normalized format (integer or float).

NumberFormatter getNumberFormatter()

Returns a preconfigured \NumberFormatter instance.

Details

__construct(int $scale = null, string $type = null)

Parameters

int $scale The scale
string $type One of the supported types

Exceptions

UnexpectedTypeException if the given value of type is unknown

See also

self::$types for a list of supported types

mixed transform(mixed $value)

Transforms between a normalized format (integer or float) into a percentage value.

Parameters

mixed $value The value in the original representation

Return Value

mixed The value in the transformed representation

Exceptions

TransformationFailedException if the given value is not numeric or if the value could not be transformed

mixed reverseTransform(mixed $value)

Transforms between a percentage value into a normalized format (integer or float).

Parameters

mixed $value The value in the transformed representation

Return Value

mixed The value in the original representation

Exceptions

TransformationFailedException if the given value is not a string or if the value could not be transformed

protected NumberFormatter getNumberFormatter()

Returns a preconfigured \NumberFormatter instance.

Return Value

NumberFormatter