SerializationInterface.php 933 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. namespace Drupal\Component\Serialization;
  3. /**
  4. * Defines an interface for serialization formats.
  5. */
  6. interface SerializationInterface {
  7. /**
  8. * Encodes data into the serialization format.
  9. *
  10. * @param mixed $data
  11. * The data to encode.
  12. *
  13. * @return string
  14. * The encoded data.
  15. *
  16. * @throws \Drupal\Component\Serialization\Exception\InvalidDataTypeException
  17. */
  18. public static function encode($data);
  19. /**
  20. * Decodes data from the serialization format.
  21. *
  22. * @param string $raw
  23. * The raw data string to decode.
  24. *
  25. * @return mixed
  26. * The decoded data.
  27. *
  28. * @throws \Drupal\Component\Serialization\Exception\InvalidDataTypeException
  29. */
  30. public static function decode($raw);
  31. /**
  32. * Gets the file extension for this serialization format.
  33. *
  34. * @return string
  35. * The file extension, without leading dot.
  36. */
  37. public static function getFileExtension();
  38. }