Core\DataTransformer\BooleanToStringTransformer (Component\Form\Extension)

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.
在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部