EncoderInterface.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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 EncoderInterface
  16. {
  17. /**
  18. * Encodes data into the given format.
  19. *
  20. * @param mixed $data Data to encode
  21. * @param string $format Format name
  22. * @param array $context Options that normalizers/encoders have access to
  23. *
  24. * @return string
  25. *
  26. * @throws UnexpectedValueException
  27. */
  28. public function encode($data, string $format, array $context = []);
  29. /**
  30. * Checks whether the serializer can encode to given format.
  31. *
  32. * @param string $format Format name
  33. *
  34. * @return bool
  35. */
  36. public function supportsEncoding(string $format);
  37. }