vendor/symfony/form/CallbackTransformer.php line 30

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of the Symfony package.
  4.  *
  5.  * (c) Fabien Potencier <fabien@symfony.com>
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. namespace Symfony\Component\Form;
  11. class CallbackTransformer implements DataTransformerInterface
  12. {
  13.     private \Closure $transform;
  14.     private \Closure $reverseTransform;
  15.     public function __construct(callable $transform, callable $reverseTransform)
  16.     {
  17.         $this->transform $transform(...);
  18.         $this->reverseTransform $reverseTransform(...);
  19.     }
  20.     /**
  21.      * {@inheritdoc}
  22.      */
  23.     public function transform(mixed $data): mixed
  24.     {
  25.         return ($this->transform)($data);
  26.     }
  27.     /**
  28.      * {@inheritdoc}
  29.      */
  30.     public function reverseTransform(mixed $data): mixed
  31.     {
  32.         return ($this->reverseTransform)($data);
  33.     }
  34. }