NormalizerInterface.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. namespace Symfony\Component\Serializer\Normalizer;
  3. use Symfony\Component\Serializer\SerializerInterface;
  4. /*
  5. * This file is part of the Symfony framework.
  6. *
  7. * (c) Fabien Potencier <fabien@symfony.com>
  8. *
  9. * This source file is subject to the MIT license that is bundled
  10. * with this source code in the file LICENSE.
  11. */
  12. /**
  13. * Defines the interface of normalizers.
  14. *
  15. * @author Jordi Boggiano <j.boggiano@seld.be>
  16. */
  17. interface NormalizerInterface
  18. {
  19. /**
  20. * Normalizes an object into a set of arrays/scalars
  21. *
  22. * @param object $object object to normalize
  23. * @param string $format format the normalization result will be encoded as
  24. * @return array|scalar
  25. * @api
  26. */
  27. function normalize($object, $format = null);
  28. /**
  29. * Denormalizes data back into an object of the given class
  30. *
  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. * @return object
  35. * @api
  36. */
  37. function denormalize($data, $class, $format = null);
  38. /**
  39. * Checks whether the given class is supported for normalization by this normalizer
  40. *
  41. * @param mixed $data Data to normalize.
  42. * @param string $format The format being (de-)serialized from or into.
  43. * @return Boolean
  44. * @api
  45. */
  46. function supportsNormalization($data, $format = null);
  47. /**
  48. * Checks whether the given class is supported for denormalization by this normalizer
  49. *
  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.
  53. * @return Boolean
  54. * @api
  55. */
  56. function supportsDenormalization($data, $type, $format = null);
  57. }