4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\Serializer\Normalizer;
14 use Symfony\Component\Serializer\Exception\BadMethodCallException;
15 use Symfony\Component\Serializer\Exception\ExtraAttributesException;
16 use Symfony\Component\Serializer\Exception\InvalidArgumentException;
17 use Symfony\Component\Serializer\Exception\LogicException;
18 use Symfony\Component\Serializer\Exception\RuntimeException;
19 use Symfony\Component\Serializer\Exception\UnexpectedValueException;
22 * Defines the interface of denormalizers.
24 * @author Jordi Boggiano <j.boggiano@seld.be>
26 interface DenormalizerInterface
29 * Denormalizes data back into an object of the given class.
31 * @param mixed $data Data to restore
32 * @param string $class The expected class to instantiate
33 * @param string $format Format the given data was extracted from
34 * @param array $context Options available to the denormalizer
38 * @throws BadMethodCallException Occurs when the normalizer is not called in an expected context
39 * @throws InvalidArgumentException Occurs when the arguments are not coherent or not supported
40 * @throws UnexpectedValueException Occurs when the item cannot be hydrated with the given data
41 * @throws ExtraAttributesException Occurs when the item doesn't have attribute to receive given data
42 * @throws LogicException Occurs when the normalizer is not supposed to denormalize
43 * @throws RuntimeException Occurs if the class cannot be instantiated
45 public function denormalize($data, $class, $format = null, array $context = array());
48 * Checks whether the given class is supported for denormalization by this normalizer.
50 * @param mixed $data Data to denormalize from
51 * @param string $type The class to which the data should be denormalized
52 * @param string $format The format being deserialized from
56 public function supportsDenormalization($data, $type, $format = null);