NormalizerInterface.php 804 B

1234567891011121314151617181920212223242526272829303132333435
  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. use ArrayObject;
  13. interface NormalizerInterface
  14. {
  15. /**
  16. * Normalizes an object into a set of arrays/scalars.
  17. *
  18. * @param mixed $object
  19. * @return null|array|ArrayObject|bool|float|int|string
  20. */
  21. public function normalize($object);
  22. /**
  23. * Denormalizes data back into an object of the given class.
  24. *
  25. * @param mixed $data Data to restore
  26. * @param string $class The expected class to instantiate
  27. * @return mixed|object
  28. */
  29. public function denormalize($data, string $class);
  30. }