Fixes #91: Made Uuid's serializable.

This commit is contained in:
frankdejonge
2015-10-25 22:15:32 +01:00
parent f77767e6f0
commit 91d0c6da31
3 changed files with 35 additions and 1 deletions
+26
View File
@@ -187,6 +187,32 @@ class Uuid implements UuidInterface
return $this->toString();
}
/**
* Converts this UUID object to a string when the object is serialized
* with `serialize()`
*
* @return string
* @link http://php.net/manual/en/class.serializable.php
*/
public function serialize()
{
return $this->toString();
}
/**
* Re-constructs the object from its serialized form.
*
* @param string $serialized
* @link http://php.net/manual/en/class.serializable.php
*/
public function unserialize($serialized)
{
$uuid = self::fromString($serialized);
$this->codec = $uuid->codec;
$this->converter = $uuid->converter;
$this->fields = $uuid->fields;
}
public function compareTo(UuidInterface $other)
{
$comparison = 0;