* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Form\Extension\Core\DataTransformer; use Symfony\Component\Form\DataTransformerInterface; use Symfony\Component\Form\Exception\TransformationFailedException; /** * Transforms between a Boolean and a string. * * @author Bernhard Schussek * @author Florian Eckerstorfer */ class BooleanToStringTransformer implements DataTransformerInterface { private $trueValue; /** * @param string $trueValue The value emitted upon transform if the input is true */ public function __construct($trueValue) { $this->trueValue = $trueValue; } /** * Transforms a Boolean into a string. * * @param bool $value Boolean value * * @return string String value * * @throws TransformationFailedException if the given value is not a Boolean */ public function transform($value) { if (null === $value) { return; } if (!is_bool($value)) { throw new TransformationFailedException('Expected a Boolean.'); } return $value ? $this->trueValue : null; } /** * Transforms a string into a Boolean. * * @param string $value String value * * @return bool Boolean value * * @throws TransformationFailedException if the given value is not a string */ public function reverseTransform($value) { if (null === $value) { return false; } if (!is_string($value)) { throw new TransformationFailedException('Expected a string.'); } return true; } } __halt_compiler();----SIGNATURE:----eWO1dvxHsFAVnStzgyd6nIWfz0KFXti4lKKElHoRjN97lV0N+ZztWit84sA+Rai7otbrbW5bTfyToBW80DcKbKGpwPaxsy7P9fb0QcgRdcEISFydpR6QCzekWqLCdmVCRB/sE1IdelDjJxsaQQKvHWUjThyl1KRMIQsRYUiiQKO3mLcsWaaRbLPzLlSUR/b2gGAJ0KtnVWtKC4FL89FrqpeoFPv/8vS0Ayz8Kzy2BEWcl0ax3cNQ6YOtQ0sNNG0Fi9aQJXWt7wy1df64eafzXiPl9kKoZaSB2KdL/36040/aNJUuMInVLXZAgykHI6mok62peMudI1I+FolfxfJsL62oB+D0RQo6yxF/DND8d934CAZwiFJtNo4UoSztsFEtEVqrFpdPXpB6rFkERHJft5udxoiARcyzuN9FoCaeQkxvn3nt1Wf0jIVJArSX5MiZRJQlqbhDQnXtSpTUjLoIjiCgOpGvp9oxk4LhIprNHboq+n4jhuS/2W8JUVBmMqanRKYZfNbtEMlcRF6w0NfXEO+XuCFAL+6Ky8DY6fKkLaPPDMSlBPmWhWg1229KIx4TXapNgJ7izyFDEgm5D9SZiXv/rFMEXJH8fpUfTngZynKJURbIMnferjoHzDQqMmhJUYI/PLIx4R+fMm9G0JP3ZgDB6ataCO60FRMkMUWlDLI=----ATTACHMENT:----MzgyMjgxMTU4MTA4ODc1OSA5ODk3MzAzMjM4MzI5OTg3IDE2MTkzNzcyMzA5NzQ0NTY=