fb45e12c650ad8dbd7be0724417f6263e63dbb41
[yaffs-website] / serializer / Tests / Fixtures / ScalarDummy.php
1 <?php
2
3 /*
4  * This file is part of the Symfony package.
5  *
6  * (c) Fabien Potencier <fabien@symfony.com>
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11
12 namespace Symfony\Component\Serializer\Tests\Fixtures;
13
14 use Symfony\Component\Serializer\Normalizer\DenormalizableInterface;
15 use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
16 use Symfony\Component\Serializer\Normalizer\NormalizableInterface;
17 use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
18
19 class ScalarDummy implements NormalizableInterface, DenormalizableInterface
20 {
21     public $foo;
22     public $xmlFoo;
23
24     public function normalize(NormalizerInterface $normalizer, $format = null, array $context = array())
25     {
26         return 'xml' === $format ? $this->xmlFoo : $this->foo;
27     }
28
29     public function denormalize(DenormalizerInterface $denormalizer, $data, $format = null, array $context = array())
30     {
31         if ('xml' === $format) {
32             $this->xmlFoo = $data;
33         } else {
34             $this->foo = $data;
35         }
36     }
37 }