ScalarDummy.php 659 B

1234567891011121314151617181920212223242526
  1. <?php
  2. namespace Symfony\Tests\Component\Serializer\Fixtures;
  3. use Symfony\Component\Serializer\Normalizer\NormalizableInterface;
  4. use Symfony\Component\Serializer\SerializerInterface;
  5. class ScalarDummy implements NormalizableInterface
  6. {
  7. public $foo;
  8. public $xmlFoo;
  9. public function normalize(SerializerInterface $serializer, $format = null)
  10. {
  11. return $format === 'xml' ? $this->xmlFoo : $this->foo;
  12. }
  13. public function denormalize(SerializerInterface $serializer, $data, $format = null)
  14. {
  15. if ($format === 'xml') {
  16. $this->xmlFoo = $data;
  17. } else {
  18. $this->foo = $data;
  19. }
  20. }
  21. }