DecoderInterface.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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\Encoder;
  11. use Symfony\Component\Serializer\Exception\UnexpectedValueException;
  12. /**
  13. * @author Jordi Boggiano <j.boggiano@seld.be>
  14. */
  15. interface DecoderInterface
  16. {
  17. /**
  18. * Decodes a string into PHP data.
  19. *
  20. * @param string $data Data to decode
  21. * @param string $format Format name
  22. * @param array $context Options that decoders have access to
  23. *
  24. * The format parameter specifies which format the data is in; valid values
  25. * depend on the specific implementation. Authors implementing this interface
  26. * are encouraged to document which formats they support in a non-inherited
  27. * phpdoc comment.
  28. *
  29. * @return mixed
  30. *
  31. * @throws UnexpectedValueException
  32. */
  33. public function decode(string $data, string $format, array $context = []);
  34. /**
  35. * Checks whether the deserializer can decode from given format.
  36. *
  37. * @param string $format Format name
  38. *
  39. * @return bool
  40. */
  41. public function supportsDecoding(string $format);
  42. }