This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
symfony/src/Symfony/Component/Form/CallbackTransformer.php
Fabien Potencier fa44efe90c Merge branch '3.4' into 4.2
* 3.4:
  [Form] various minor fixes
  bugfix: the terminal state was wrong and not reseted
  [Console] Fix inconsistent result for choice questions in non-interactive mode
  Define null return type for Constraint::getDefaultOption()
  [HttpKernel] Fix DebugHandlersListener constructor docblock
  Skip Glob brace test when GLOB_BRACE is unavailable
  bumped Symfony version to 3.4.25
  updated VERSION for 3.4.24
  update CONTRIBUTORS for 3.4.24
  updated CHANGELOG for 3.4.24
  [EventDispatcher] cleanup
2019-04-06 15:51:08 +02:00

45 lines
1012 B
PHP

<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Form;
class CallbackTransformer implements DataTransformerInterface
{
private $transform;
private $reverseTransform;
/**
* @param callable $transform The forward transform callback
* @param callable $reverseTransform The reverse transform callback
*/
public function __construct(callable $transform, callable $reverseTransform)
{
$this->transform = $transform;
$this->reverseTransform = $reverseTransform;
}
/**
* {@inheritdoc}
*/
public function transform($data)
{
return ($this->transform)($data);
}
/**
* {@inheritdoc}
*/
public function reverseTransform($data)
{
return ($this->reverseTransform)($data);
}
}