Symfony2 API
Class

Symfony\Component\Form\Extension\Core\DataTransformer\PercentToLocalizedStringTransformer

class PercentToLocalizedStringTransformer implements DataTransformerInterface

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

Constants

FRACTIONAL

INTEGER

Methods

__construct(integer $precision = null, string $type = null)

Constructor.

number transform(number $value)

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

number reverseTransform(number $value)

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

Details

at line 48
public __construct(integer $precision = null, string $type = null)

Constructor.

Parameters

integer $precision The precision
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

at line 76
public number transform(number $value)

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

Parameters

number $value Normalized value

Return Value

number Percentage value

Exceptions

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

at line 111
public number reverseTransform(number $value)

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

Parameters

number $value Percentage value.

Return Value

number Normalized value.

Exceptions

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