Serializer.php 971 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. /**
  3. * Lithium: the most rad php framework
  4. *
  5. * @copyright Copyright 2013, Union of RAD (http://union-of-rad.org)
  6. * @license http://opensource.org/licenses/bsd-license.php The BSD License
  7. */
  8. namespace lithium\storage\cache\strategy;
  9. /**
  10. * An PHP Serialization strategy.
  11. */
  12. class Serializer extends \lithium\core\Object {
  13. /**
  14. * Write strategy method.
  15. *
  16. * Serializes the passed data.
  17. *
  18. * @link http://php.net/manual/en/function.serialize.php PHP Manual: serialize()
  19. * @param mixed $data The data to be serialized.
  20. * @return string Serialized data.
  21. */
  22. public function write($data) {
  23. return serialize($data);
  24. }
  25. /**
  26. * Read strategy method.
  27. *
  28. * Unserializes the passed data.
  29. *
  30. * @link http://php.net/manual/en/function.unserialize.php PHP Manual: unserialize()
  31. * @param string $data Serialized data.
  32. * @return mixed Result of unserialization.
  33. */
  34. public function read($data) {
  35. return unserialize($data);
  36. }
  37. }
  38. ?>