ScalarDummy.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  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\Serializer\Tests\Fixtures;
  11. use Symfony\Component\Serializer\Normalizer\NormalizableInterface;
  12. use Symfony\Component\Serializer\Normalizer\DenormalizableInterface;
  13. use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
  14. use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
  15. class ScalarDummy implements NormalizableInterface, DenormalizableInterface
  16. {
  17. public $foo;
  18. public $xmlFoo;
  19. public function normalize(NormalizerInterface $normalizer, $format = null, array $context = array())
  20. {
  21. return $format === 'xml' ? $this->xmlFoo : $this->foo;
  22. }
  23. public function denormalize(DenormalizerInterface $denormalizer, $data, $format = null, array $context = array())
  24. {
  25. if ($format === 'xml') {
  26. $this->xmlFoo = $data;
  27. } else {
  28. $this->foo = $data;
  29. }
  30. }
  31. }