NormalizerInterface.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. * @param array $properties a list of properties to extract, if null all properties are returned
  25. * @return array|scalar
  26. * @api
  27. */
  28. function normalize($object, $format, $properties = null);
  29. /**
  30. * Denormalizes data back into an object of the given class
  31. *
  32. * @param mixed $data data to restore
  33. * @param string $class the expected class to instantiate
  34. * @param string $format format the given data was extracted from
  35. * @return object
  36. * @api
  37. */
  38. function denormalize($data, $class, $format = null);
  39. /**
  40. * Checks whether the given class is supported for normalization by this normalizer
  41. *
  42. * @param mixed $data Data to normalize.
  43. * @param string $format The format being (de-)serialized from or into.
  44. * @return Boolean
  45. * @api
  46. */
  47. function supportsNormalization($data, $format = null);
  48. /**
  49. * Checks whether the given class is supported for denormalization by this normalizer
  50. *
  51. * @param mixed $data Data to denormalize from.
  52. * @param string $type The class to which the data should be denormalized.
  53. * @param string $format The format being deserialized from.
  54. * @return Boolean
  55. * @api
  56. */
  57. function supportsDenormalization($data, $type, $format = null);
  58. /**
  59. * Sets the owning Serializer object
  60. *
  61. * @param SerializerInterface $serializer
  62. * @api
  63. */
  64. function setSerializer(SerializerInterface $serializer);
  65. /**
  66. * Gets the owning Serializer object
  67. *
  68. * @return SerializerInterface
  69. * @api
  70. */
  71. function getSerializer();
  72. }