NormalizerInterface.php 786 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * This file is part of Hyperf.
  5. *
  6. * @link https://www.hyperf.io
  7. * @document https://hyperf.wiki
  8. * @contact group@hyperf.io
  9. * @license https://github.com/hyperf/hyperf/blob/master/LICENSE
  10. */
  11. namespace Hyperf\Contract;
  12. interface NormalizerInterface
  13. {
  14. /**
  15. * Normalizes an object into a set of arrays/scalars.
  16. *
  17. * @param mixed $object
  18. * @return null|array|\ArrayObject|bool|float|int|string
  19. */
  20. public function normalize($object);
  21. /**
  22. * Denormalizes data back into an object of the given class.
  23. *
  24. * @param mixed $data Data to restore
  25. * @param string $class The expected class to instantiate
  26. * @return mixed|object
  27. */
  28. public function denormalize($data, string $class);
  29. }