functions.php 804 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. /* ===========================================================================
  3. * Copyright (c) 2018 Zindex Software
  4. *
  5. * Licensed under the MIT License
  6. * =========================================================================== */
  7. namespace Opis\Closure;
  8. /**
  9. * Serialize
  10. *
  11. * @param $data
  12. * @return string
  13. */
  14. function serialize($data)
  15. {
  16. SerializableClosure::enterContext();
  17. SerializableClosure::wrapClosures($data);
  18. $data = \serialize($data);
  19. SerializableClosure::exitContext();
  20. return $data;
  21. }
  22. /**
  23. * Unserialize
  24. *
  25. * @param $data
  26. * @return mixed
  27. */
  28. function unserialize($data)
  29. {
  30. SerializableClosure::enterContext();
  31. $data = \unserialize($data);
  32. SerializableClosure::unwrapClosures($data);
  33. SerializableClosure::exitContext();
  34. return $data;
  35. }