diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e1488e..f0e88d2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. * `getMostSignificantBitsHex()` * `getTimeHiAndVersion()` * `getTimeHiAndVersionHex()` + * `getTimeLow()` + * `getTimeLowHex()` * Remove dependency on ramsey/collection package. diff --git a/phpstan.neon.dist b/phpstan.neon.dist index f4c391c..ba132b2 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -14,7 +14,7 @@ parameters: - # Legacy methods of `Ramsey\Uuid` use interface methods that are NOT defined on `FieldsInterface` message: '#^Call to an undefined method Ramsey\\Uuid\\Fields\\FieldsInterface::get.*$#' - count: 8 + count: 7 path: ./src/Lazy/LazyUuidFromString.php - message: '#^Result of \|\| is always false\.$#' diff --git a/src/DeprecatedUuidInterface.php b/src/DeprecatedUuidInterface.php index 1820029..90c21cf 100644 --- a/src/DeprecatedUuidInterface.php +++ b/src/DeprecatedUuidInterface.php @@ -53,14 +53,6 @@ interface DeprecatedUuidInterface */ public function getNodeHex(): string; - /** - * @deprecated Use {@see UuidInterface::getFields()} to get a - * {@see FieldsInterface} instance. If it is a - * {@see \Ramsey\Uuid\Rfc4122\FieldsInterface} instance, you may call - * {@see \Ramsey\Uuid\Rfc4122\FieldsInterface::getTimeLow()}. - */ - public function getTimeLowHex(): string; - /** * @deprecated Use {@see UuidInterface::getFields()} to get a * {@see FieldsInterface} instance. If it is a diff --git a/src/DeprecatedUuidMethodsTrait.php b/src/DeprecatedUuidMethodsTrait.php index 8e16b35..3e02b1b 100644 --- a/src/DeprecatedUuidMethodsTrait.php +++ b/src/DeprecatedUuidMethodsTrait.php @@ -164,28 +164,6 @@ trait DeprecatedUuidMethodsTrait return $this->fields->getNode()->toString(); } - /** - * @deprecated Use {@see UuidInterface::getFields()} to get a - * {@see FieldsInterface} instance. If it is a {@see Rfc4122FieldsInterface} - * instance, you may call {@see Rfc4122FieldsInterface::getTimeLow()} - * and use the arbitrary-precision math library of your choice to - * convert it to a string integer. - */ - public function getTimeLow(): string - { - return $this->numberConverter->fromHex($this->fields->getTimeLow()->toString()); - } - - /** - * @deprecated Use {@see UuidInterface::getFields()} to get a - * {@see FieldsInterface} instance. If it is a {@see Rfc4122FieldsInterface} - * instance, you may call {@see Rfc4122FieldsInterface::getTimeLow()}. - */ - public function getTimeLowHex(): string - { - return $this->fields->getTimeLow()->toString(); - } - /** * @deprecated Use {@see UuidInterface::getFields()} to get a * {@see FieldsInterface} instance. If it is a {@see Rfc4122FieldsInterface} diff --git a/src/Lazy/LazyUuidFromString.php b/src/Lazy/LazyUuidFromString.php index aeda1bc..cbf92f4 100644 --- a/src/Lazy/LazyUuidFromString.php +++ b/src/Lazy/LazyUuidFromString.php @@ -162,13 +162,6 @@ final class LazyUuidFromString implements UuidInterface ->getNodeHex(); } - /** @psalm-suppress DeprecatedMethod */ - public function getTimeLowHex(): string - { - return ($this->unwrapped ?? $this->unwrap()) - ->getTimeLowHex(); - } - /** @psalm-suppress DeprecatedMethod */ public function getTimeMidHex(): string { @@ -361,30 +354,6 @@ final class LazyUuidFromString implements UuidInterface ); } - /** - * @deprecated Use {@see UuidInterface::getFields()} to get a - * {@see FieldsInterface} instance. If it is a {@see Rfc4122FieldsInterface} - * instance, you may call {@see Rfc4122FieldsInterface::getTimeLow()} - * and use the arbitrary-precision math library of your choice to - * convert it to a string integer. - * - * @psalm-suppress UndefinedInterfaceMethod - * @psalm-suppress DeprecatedMethod - * @psalm-suppress MixedArgument - * @psalm-suppress MixedMethodCall - */ - public function getTimeLow(): string - { - $instance = ($this->unwrapped ?? $this->unwrap()); - - return $instance->getNumberConverter() - ->fromHex( - $instance->getFields() - ->getTimeLow() - ->toString() - ); - } - /** * @deprecated Use {@see UuidInterface::getFields()} to get a * {@see FieldsInterface} instance. If it is a {@see Rfc4122FieldsInterface} diff --git a/tests/ExpectedBehaviorTest.php b/tests/ExpectedBehaviorTest.php index 9999277..0a08d0f 100644 --- a/tests/ExpectedBehaviorTest.php +++ b/tests/ExpectedBehaviorTest.php @@ -53,11 +53,11 @@ class ExpectedBehaviorTest extends TestCase $this->assertArrayHasKey('clock_seq_hi_and_reserved', $uuid->getFieldsHex()); $this->assertArrayHasKey('clock_seq_low', $uuid->getFieldsHex()); $this->assertArrayHasKey('node', $uuid->getFieldsHex()); - $this->assertIsString($uuid->getTimeLowHex()); + $this->assertIsString($uuid->getFields()->getTimeLow()->toString()); $this->assertIsString($uuid->getTimeMidHex()); $this->assertIsString($uuid->getFields()->getTimeHiAndVersion()->toString()); $this->assertIsString($uuid->getNodeHex()); - $this->assertSame($uuid->getFieldsHex()['time_low'], $uuid->getTimeLowHex()); + $this->assertSame($uuid->getFieldsHex()['time_low'], $uuid->getFields()->getTimeLow()->toString()); $this->assertSame($uuid->getFieldsHex()['time_mid'], $uuid->getTimeMidHex()); $this->assertSame( $uuid->getFieldsHex()['time_hi_and_version'], @@ -69,7 +69,7 @@ class ExpectedBehaviorTest extends TestCase $this->assertSame( (string) $uuid->getHex(), - $uuid->getTimeLowHex() + $uuid->getFields()->getTimeLow()->toString() . $uuid->getTimeMidHex() . $uuid->getFields()->getTimeHiAndVersion()->toString() . $uuid->getFields()->getClockSeqHiAndReserved()->toString() @@ -95,7 +95,7 @@ class ExpectedBehaviorTest extends TestCase $this->assertSame( $uuid->toString(), - $uuid->getTimeLowHex() . '-' + $uuid->getFields()->getTimeLow()->toString() . '-' . $uuid->getTimeMidHex() . '-' . $uuid->getFields()->getTimeHiAndVersion()->toString() . '-' . $uuid->getFields()->getClockSeqHiAndReserved()->toString() @@ -105,7 +105,7 @@ class ExpectedBehaviorTest extends TestCase $this->assertSame( (string) $uuid, - $uuid->getTimeLowHex() . '-' + $uuid->getFields()->getTimeLow()->toString() . '-' . $uuid->getTimeMidHex() . '-' . $uuid->getFields()->getTimeHiAndVersion()->toString() . '-' . $uuid->getFields()->getClockSeqHiAndReserved()->toString() @@ -254,7 +254,7 @@ class ExpectedBehaviorTest extends TestCase $components = explode('-', $string); - $this->assertSame($components[0], $uuid->getTimeLowHex()); + $this->assertSame($components[0], $uuid->getFields()->getTimeLow()->toString()); $this->assertSame($components[1], $uuid->getTimeMidHex()); $this->assertSame($components[2], $uuid->getFields()->getTimeHiAndVersion()->toString()); $this->assertSame( @@ -284,7 +284,7 @@ class ExpectedBehaviorTest extends TestCase $components = explode('-', $string); - $this->assertSame($components[0], $uuid->getTimeLowHex()); + $this->assertSame($components[0], $uuid->getFields()->getTimeLow()->toString()); $this->assertSame($components[1], $uuid->getTimeMidHex()); $this->assertSame($components[2], $uuid->getFields()->getTimeHiAndVersion()->toString()); $this->assertSame( @@ -314,7 +314,7 @@ class ExpectedBehaviorTest extends TestCase $components = explode('-', $string); - $this->assertSame($components[0], $uuid->getTimeLowHex()); + $this->assertSame($components[0], $uuid->getFields()->getTimeLow()->toString()); $this->assertSame($components[1], $uuid->getTimeMidHex()); $this->assertSame($components[2], $uuid->getFields()->getTimeHiAndVersion()->toString()); $this->assertSame( diff --git a/tests/UuidTest.php b/tests/UuidTest.php index 83934ee..a852528 100644 --- a/tests/UuidTest.php +++ b/tests/UuidTest.php @@ -324,17 +324,11 @@ class UuidTest extends TestCase $this->assertSame('11e1', $uuid->getFields()->getTimeHiAndVersion()->toString()); } - public function testGetTimeLow(): void - { - /** @var Uuid $uuid */ - $uuid = Uuid::fromString('ff6f8cb0-c57d-11e1-9b21-0800200c9a66'); - $this->assertSame('4285500592', $uuid->getTimeLow()); - } - public function testGetTimeLowHex(): void { + /** @var \Ramsey\Uuid\Rfc4122\UuidInterface $uuid */ $uuid = Uuid::fromString('ff6f8cb0-c57d-11e1-9b21-0800200c9a66'); - $this->assertSame('ff6f8cb0', $uuid->getTimeLowHex()); + $this->assertSame('ff6f8cb0', $uuid->getFields()->getTimeLow()->toString()); } public function testGetTimeMid(): void @@ -926,7 +920,7 @@ class UuidTest extends TestCase $uuidA = Uuid::uuid1(0x00007ffffffe, 0x1669); $this->assertSame('c4dbe7e2-097f-11e2-9669-00007ffffffe', (string) $uuidA); - $this->assertSame('c4dbe7e2', $uuidA->getTimeLowHex()); + $this->assertSame('c4dbe7e2', $uuidA->getFields()->getTimeLow()->toString()); $this->assertSame('097f', $uuidA->getTimeMidHex()); $this->assertSame('11e2', $uuidA->getFields()->getTimeHiAndVersion()->toString()); @@ -937,7 +931,7 @@ class UuidTest extends TestCase $uuidB = Uuid::uuid1(0x00007ffffffe, 0x1669); $this->assertSame('c4b18100-097f-11e2-9669-00007ffffffe', (string) $uuidB); - $this->assertSame('c4b18100', $uuidB->getTimeLowHex()); + $this->assertSame('c4b18100', $uuidB->getFields()->getTimeLow()->toString()); $this->assertSame('097f', $uuidB->getTimeMidHex()); $this->assertSame('11e2', $uuidB->getFields()->getTimeHiAndVersion()->toString()); @@ -948,7 +942,7 @@ class UuidTest extends TestCase $uuidC = Uuid::uuid1(0x00007ffffffe, 0x1669); $this->assertSame('c54a1776-097f-11e2-9669-00007ffffffe', (string) $uuidC); - $this->assertSame('c54a1776', $uuidC->getTimeLowHex()); + $this->assertSame('c54a1776', $uuidC->getFields()->getTimeLow()->toString()); $this->assertSame('097f', $uuidC->getTimeMidHex()); $this->assertSame('11e2', $uuidC->getFields()->getTimeHiAndVersion()->toString()); } @@ -967,7 +961,7 @@ class UuidTest extends TestCase $uuidA = Uuid::uuid1(0x00007ffffffe, 0x1669); $this->assertSame('ff9785f6-ffff-1fff-9669-00007ffffffe', (string) $uuidA); - $this->assertSame('ff9785f6', $uuidA->getTimeLowHex()); + $this->assertSame('ff9785f6', $uuidA->getFields()->getTimeLow()->toString()); $this->assertSame('ffff', $uuidA->getTimeMidHex()); $this->assertSame('1fff', $uuidA->getFields()->getTimeHiAndVersion()->toString()); @@ -982,7 +976,7 @@ class UuidTest extends TestCase $uuidB = Uuid::uuid1(0x00007ffffffe, 0x1669); $this->assertSame('00000000-0000-1000-9669-00007ffffffe', (string) $uuidB); - $this->assertSame('00000000', $uuidB->getTimeLowHex()); + $this->assertSame('00000000', $uuidB->getFields()->getTimeLow()->toString()); $this->assertSame('0000', $uuidB->getTimeMidHex()); $this->assertSame('1000', $uuidB->getFields()->getTimeHiAndVersion()->toString()); } @@ -1187,7 +1181,7 @@ class UuidTest extends TestCase $this->assertSame(base64_decode($bytes), $uuid->getBytes()); $this->assertSame($int, $uuid->getInteger()->toString()); $this->assertSame($fields, $uuid->getFieldsHex()); - $this->assertSame($fields['time_low'], $uuid->getTimeLowHex()); + $this->assertSame($fields['time_low'], $uuid->getFields()->getTimeLow()->toString()); $this->assertSame($fields['time_mid'], $uuid->getTimeMidHex()); $this->assertSame($fields['time_hi_and_version'], $uuid->getFields()->getTimeHiAndVersion()->toString()); $this->assertSame( diff --git a/tests/static-analysis/UuidIsImmutable.php b/tests/static-analysis/UuidIsImmutable.php index 4717d15..ae97863 100644 --- a/tests/static-analysis/UuidIsImmutable.php +++ b/tests/static-analysis/UuidIsImmutable.php @@ -57,7 +57,6 @@ final class UuidIsImmutable $a->getDateTime(), $a->getInteger(), $a->getNodeHex(), - $a->getTimeLowHex(), $a->getTimeMidHex(), $a->getTimestampHex(), $a->getUrn(),