diff --git a/.gitignore b/.gitignore index de2b378..0a59599 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.idea/ *.phar .DS_Store build diff --git a/composer.json b/composer.json index 8adc973..30de67e 100644 --- a/composer.json +++ b/composer.json @@ -20,7 +20,7 @@ "source": "https://github.com/ramsey/uuid" }, "require": { - "php": ">=5.3.3" + "php": ">=5.4" }, "require-dev": { "moontoast/math": "~1.1", diff --git a/src/Uuid.php b/src/Uuid.php index 40c2587..3f8a349 100644 --- a/src/Uuid.php +++ b/src/Uuid.php @@ -29,7 +29,7 @@ use InvalidArgumentException; * @link http://docs.python.org/3/library/uuid.html * @link http://docs.oracle.com/javase/6/docs/api/java/util/UUID.html */ -final class Uuid +final class Uuid implements \JsonSerializable { /** * When this namespace is specified, the name string is a fully-qualified domain name. @@ -175,6 +175,19 @@ final class Uuid return $this->toString(); } + /** + * Converts this UUID object to a string when the object is serialized + * with json_encode() + * + * @link http://php.net/manual/en/class.jsonserializable.php + * + * @return string + */ + public function jsonSerialize() + { + return $this->toString(); + } + /** * Compares this UUID with the specified UUID. *