W3cubDocs

/Symfony 2.7

Symfony\Component\Form\Extension\Core\DataTransformer\BooleanToStringTransformer

class BooleanToStringTransformer implements DataTransformerInterface

Transforms between a Boolean and a string.

Methods

__construct(string $trueValue)

Sets the value emitted upon transform if the input is true.

string transform(bool $value)

Transforms a Boolean into a string.

bool reverseTransform(string $value)

Transforms a string into a Boolean.

Details

public __construct(string $trueValue)

Sets the value emitted upon transform if the input is true.

Parameters

string $trueValue

public string transform(bool $value)

Transforms a Boolean into a string.

Parameters

bool $value Boolean value.

Return Value

string String value.

Exceptions

TransformationFailedException If the given value is not a Boolean.

public bool reverseTransform(string $value)

Transforms a string into a Boolean.

Parameters

string $value String value.

Return Value

bool Boolean value.

Exceptions

TransformationFailedException If the given value is not a string.