NormalizableInterface.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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\Normalizer;
  11. /**
  12. * Defines the most basic interface a class must implement to be normalizable.
  13. *
  14. * If a normalizer is registered for the class and it doesn't implement
  15. * the Normalizable interfaces, the normalizer will be used instead.
  16. *
  17. * @author Jordi Boggiano <j.boggiano@seld.be>
  18. */
  19. interface NormalizableInterface
  20. {
  21. /**
  22. * Normalizes the object into an array of scalars|arrays.
  23. *
  24. * It is important to understand that the normalize() call should normalize
  25. * recursively all child objects of the implementor.
  26. *
  27. * @param NormalizerInterface $normalizer The normalizer is given so that you
  28. * can use it to normalize objects contained within this object
  29. * @param string|null $format The format is optionally given to be able to normalize differently
  30. * based on different output formats
  31. * @param array $context Options for normalizing this object
  32. *
  33. * @return array|string|int|float|bool
  34. */
  35. public function normalize(NormalizerInterface $normalizer, string $format = null, array $context = []);
  36. }