vendor/symfony/serializer/Normalizer/DenormalizerInterface.php line 58

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of the Symfony package.
  4.  *
  5.  * (c) Fabien Potencier <fabien@symfony.com>
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. namespace Symfony\Component\Serializer\Normalizer;
  11. use Symfony\Component\Serializer\Exception\BadMethodCallException;
  12. use Symfony\Component\Serializer\Exception\ExceptionInterface;
  13. use Symfony\Component\Serializer\Exception\ExtraAttributesException;
  14. use Symfony\Component\Serializer\Exception\InvalidArgumentException;
  15. use Symfony\Component\Serializer\Exception\LogicException;
  16. use Symfony\Component\Serializer\Exception\RuntimeException;
  17. use Symfony\Component\Serializer\Exception\UnexpectedValueException;
  18. /**
  19.  * @author Jordi Boggiano <j.boggiano@seld.be>
  20.  */
  21. interface DenormalizerInterface
  22. {
  23.     public const COLLECT_DENORMALIZATION_ERRORS 'collect_denormalization_errors';
  24.     /**
  25.      * Denormalizes data back into an object of the given class.
  26.      *
  27.      * @param mixed  $data    Data to restore
  28.      * @param string $type    The expected class to instantiate
  29.      * @param string $format  Format the given data was extracted from
  30.      * @param array  $context Options available to the denormalizer
  31.      *
  32.      * @return mixed
  33.      *
  34.      * @throws BadMethodCallException   Occurs when the normalizer is not called in an expected context
  35.      * @throws InvalidArgumentException Occurs when the arguments are not coherent or not supported
  36.      * @throws UnexpectedValueException Occurs when the item cannot be hydrated with the given data
  37.      * @throws ExtraAttributesException Occurs when the item doesn't have attribute to receive given data
  38.      * @throws LogicException           Occurs when the normalizer is not supposed to denormalize
  39.      * @throws RuntimeException         Occurs if the class cannot be instantiated
  40.      * @throws ExceptionInterface       Occurs for all the other cases of errors
  41.      */
  42.     public function denormalize($datastring $typestring $format null, array $context = []);
  43.     /**
  44.      * Checks whether the given class is supported for denormalization by this normalizer.
  45.      *
  46.      * @param mixed  $data   Data to denormalize from
  47.      * @param string $type   The class to which the data should be denormalized
  48.      * @param string $format The format being deserialized from
  49.      *
  50.      * @return bool
  51.      */
  52.     public function supportsDenormalization($datastring $typestring $format null);
  53. }