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\BadMethodCallException;
|
Chris@17
|
15 use Symfony\Component\Serializer\Exception\ExceptionInterface;
|
Chris@12
|
16 use Symfony\Component\Serializer\Exception\ExtraAttributesException;
|
Chris@12
|
17 use Symfony\Component\Serializer\Exception\InvalidArgumentException;
|
Chris@12
|
18 use Symfony\Component\Serializer\Exception\LogicException;
|
Chris@12
|
19 use Symfony\Component\Serializer\Exception\RuntimeException;
|
Chris@12
|
20 use Symfony\Component\Serializer\Exception\UnexpectedValueException;
|
Chris@12
|
21
|
Chris@0
|
22 /**
|
Chris@0
|
23 * Defines the interface of denormalizers.
|
Chris@0
|
24 *
|
Chris@0
|
25 * @author Jordi Boggiano <j.boggiano@seld.be>
|
Chris@0
|
26 */
|
Chris@0
|
27 interface DenormalizerInterface
|
Chris@0
|
28 {
|
Chris@0
|
29 /**
|
Chris@0
|
30 * Denormalizes data back into an object of the given class.
|
Chris@0
|
31 *
|
Chris@14
|
32 * @param mixed $data Data to restore
|
Chris@14
|
33 * @param string $class The expected class to instantiate
|
Chris@14
|
34 * @param string $format Format the given data was extracted from
|
Chris@14
|
35 * @param array $context Options available to the denormalizer
|
Chris@0
|
36 *
|
Chris@0
|
37 * @return object
|
Chris@12
|
38 *
|
Chris@12
|
39 * @throws BadMethodCallException Occurs when the normalizer is not called in an expected context
|
Chris@12
|
40 * @throws InvalidArgumentException Occurs when the arguments are not coherent or not supported
|
Chris@12
|
41 * @throws UnexpectedValueException Occurs when the item cannot be hydrated with the given data
|
Chris@12
|
42 * @throws ExtraAttributesException Occurs when the item doesn't have attribute to receive given data
|
Chris@12
|
43 * @throws LogicException Occurs when the normalizer is not supposed to denormalize
|
Chris@12
|
44 * @throws RuntimeException Occurs if the class cannot be instantiated
|
Chris@17
|
45 * @throws ExceptionInterface Occurs for all the other cases of errors
|
Chris@0
|
46 */
|
Chris@17
|
47 public function denormalize($data, $class, $format = null, array $context = []);
|
Chris@0
|
48
|
Chris@0
|
49 /**
|
Chris@0
|
50 * Checks whether the given class is supported for denormalization by this normalizer.
|
Chris@0
|
51 *
|
Chris@0
|
52 * @param mixed $data Data to denormalize from
|
Chris@0
|
53 * @param string $type The class to which the data should be denormalized
|
Chris@0
|
54 * @param string $format The format being deserialized from
|
Chris@0
|
55 *
|
Chris@0
|
56 * @return bool
|
Chris@0
|
57 */
|
Chris@0
|
58 public function supportsDenormalization($data, $type, $format = null);
|
Chris@0
|
59 }
|