From ffc400e009904e22d254b4ef503fb0c4fb8a3d17 Mon Sep 17 00:00:00 2001 From: Ben Ramsey Date: Fri, 27 Dec 2019 12:23:44 -0500 Subject: [PATCH] Change UuidInterface::getInteger() to always return a string value --- CHANGELOG.md | 4 ++++ src/Uuid.php | 2 +- src/UuidInterface.php | 4 +--- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fda91bf..439a686 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,6 +42,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. * Introduce `TimeConverterInterface $timeConverter` as fourth required constructor parameter for `Uuid` and second required constructor parameter for `Builder\DefaultUuidBuilder` and `Builder\DegradedUuidBuilder`. +* Change `UuidInterface::getInteger()` to always return a `string` value instead + of `mixed`. This is a string representation of a 128-bit integer. You may then + use a math library of your choice (bcmath, gmp, etc.) to operate on the + string integer. * Change methods in converter interfaces to accept and return string values instead of `mixed`; this simplifies the interface and makes it consistent: * `NumberConverterInterface::fromHex(string $hex): string` diff --git a/src/Uuid.php b/src/Uuid.php index 76379bf..a736aea 100644 --- a/src/Uuid.php +++ b/src/Uuid.php @@ -419,7 +419,7 @@ class Uuid implements UuidInterface * * @inheritDoc */ - public function getInteger() + public function getInteger(): string { return $this->numberConverter->fromHex($this->getHex()); } diff --git a/src/UuidInterface.php b/src/UuidInterface.php index a68e47e..39fec65 100644 --- a/src/UuidInterface.php +++ b/src/UuidInterface.php @@ -130,10 +130,8 @@ interface UuidInterface extends JsonSerializable, Serializable /** * Returns the 128-bit integer value of the UUID as a string - * - * @return string */ - public function getInteger(); + public function getInteger(): string; /** * Returns the least significant 64 bits of the UUID