5cccdb3360095c3083538e764b7f10150c8063ca
[yaffs-website] / vendor / symfony / serializer / Normalizer / NormalizerInterface.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\Normalizer;
13
14 use Symfony\Component\Serializer\Exception\CircularReferenceException;
15 use Symfony\Component\Serializer\Exception\InvalidArgumentException;
16 use Symfony\Component\Serializer\Exception\LogicException;
17
18 /**
19  * Defines the interface of normalizers.
20  *
21  * @author Jordi Boggiano <j.boggiano@seld.be>
22  */
23 interface NormalizerInterface
24 {
25     /**
26      * Normalizes an object into a set of arrays/scalars.
27      *
28      * @param mixed  $object  Object to normalize
29      * @param string $format  Format the normalization result will be encoded as
30      * @param array  $context Context options for the normalizer
31      *
32      * @return array|string|int|float|bool
33      *
34      * @throws InvalidArgumentException   Occurs when the object given is not an attempted type for the normalizer
35      * @throws CircularReferenceException Occurs when the normalizer detects a circular reference when no circular
36      *                                    reference handler can fix it
37      * @throws LogicException             Occurs when the normalizer is not called in an expected context
38      */
39     public function normalize($object, $format = null, array $context = array());
40
41     /**
42      * Checks whether the given class is supported for normalization by this normalizer.
43      *
44      * @param mixed  $data   Data to normalize
45      * @param string $format The format being (de-)serialized from or into
46      *
47      * @return bool
48      */
49     public function supportsNormalization($data, $format = null);
50 }