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/ValueTransformer/ReversedTransformer.php

56 lines
1.3 KiB
PHP
Raw Normal View History

<?php
2010-10-02 11:38:11 +01:00
/*
* This file is part of the Symfony package.
2010-10-02 11:38:11 +01:00
*
* (c) Fabien Potencier <fabien@symfony.com>
2010-10-02 11:38:11 +01:00
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
2010-10-02 11:38:11 +01:00
*/
namespace Symfony\Component\Form\ValueTransformer;
/**
* Reverses a transformer
*
* When the transform() method is called, the reversed transformer's
* reverseTransform() method is called and vice versa.
*
* @author Bernhard Schussek <bernhard.schussek@symfony.com>
*/
class ReversedTransformer implements ValueTransformerInterface
{
/**
* The reversed transformer
* @var ValueTransformerInterface
*/
protected $reversedTransformer;
/**
* Reverses this transformer
*
* @param ValueTransformerInterface $innerTransformer
*/
public function __construct(ValueTransformerInterface $reversedTransformer)
{
$this->reversedTransformer = $reversedTransformer;
}
/**
* {@inheritDoc}
*/
public function transform($value)
{
return $this->reversedTransformer->reverseTransform($value, null);
}
/**
* {@inheritDoc}
*/
public function reverseTransform($value)
{
return $this->reversedTransformer->transform($value);
}
}