Chris@0
|
1 <?php
|
Chris@0
|
2
|
Chris@0
|
3 /*
|
Chris@0
|
4 * This file is part of the Symfony package.
|
Chris@0
|
5 *
|
Chris@0
|
6 * (c) Fabien Potencier <fabien@symfony.com>
|
Chris@0
|
7 *
|
Chris@0
|
8 * For the full copyright and license information, please view the LICENSE
|
Chris@0
|
9 * file that was distributed with this source code.
|
Chris@0
|
10 */
|
Chris@0
|
11
|
Chris@0
|
12 namespace Symfony\Component\Serializer\Normalizer;
|
Chris@0
|
13
|
Chris@12
|
14 use Symfony\Component\Serializer\Exception\CircularReferenceException;
|
Chris@17
|
15 use Symfony\Component\Serializer\Exception\ExceptionInterface;
|
Chris@12
|
16 use Symfony\Component\Serializer\Exception\InvalidArgumentException;
|
Chris@12
|
17 use Symfony\Component\Serializer\Exception\LogicException;
|
Chris@12
|
18
|
Chris@0
|
19 /**
|
Chris@0
|
20 * Defines the interface of normalizers.
|
Chris@0
|
21 *
|
Chris@0
|
22 * @author Jordi Boggiano <j.boggiano@seld.be>
|
Chris@0
|
23 */
|
Chris@0
|
24 interface NormalizerInterface
|
Chris@0
|
25 {
|
Chris@0
|
26 /**
|
Chris@0
|
27 * Normalizes an object into a set of arrays/scalars.
|
Chris@0
|
28 *
|
Chris@16
|
29 * @param mixed $object Object to normalize
|
Chris@14
|
30 * @param string $format Format the normalization result will be encoded as
|
Chris@0
|
31 * @param array $context Context options for the normalizer
|
Chris@0
|
32 *
|
Chris@14
|
33 * @return array|string|int|float|bool
|
Chris@12
|
34 *
|
Chris@12
|
35 * @throws InvalidArgumentException Occurs when the object given is not an attempted type for the normalizer
|
Chris@12
|
36 * @throws CircularReferenceException Occurs when the normalizer detects a circular reference when no circular
|
Chris@12
|
37 * reference handler can fix it
|
Chris@12
|
38 * @throws LogicException Occurs when the normalizer is not called in an expected context
|
Chris@17
|
39 * @throws ExceptionInterface Occurs for all the other cases of errors
|
Chris@0
|
40 */
|
Chris@17
|
41 public function normalize($object, $format = null, array $context = []);
|
Chris@0
|
42
|
Chris@0
|
43 /**
|
Chris@0
|
44 * Checks whether the given class is supported for normalization by this normalizer.
|
Chris@0
|
45 *
|
Chris@0
|
46 * @param mixed $data Data to normalize
|
Chris@0
|
47 * @param string $format The format being (de-)serialized from or into
|
Chris@0
|
48 *
|
Chris@0
|
49 * @return bool
|
Chris@0
|
50 */
|
Chris@0
|
51 public function supportsNormalization($data, $format = null);
|
Chris@0
|
52 }
|