Remove checks for methods, since the interface now has them

This commit is contained in:
Ben Ramsey
2025-12-13 21:52:15 -06:00
parent c3005a98bb
commit d11af7e93f
3 changed files with 4 additions and 35 deletions
+2 -20
View File
@@ -20,7 +20,6 @@ use Ramsey\Uuid\Codec\CodecInterface;
use Ramsey\Uuid\Converter\NumberConverterInterface;
use Ramsey\Uuid\Converter\TimeConverterInterface;
use Ramsey\Uuid\Exception\InvalidArgumentException;
use Ramsey\Uuid\Exception\UnsupportedOperationException;
use Ramsey\Uuid\Lazy\LazyUuidFromString;
use Ramsey\Uuid\Rfc4122\FieldsInterface as Rfc4122FieldsInterface;
use Ramsey\Uuid\Rfc4122\UuidInterface as Rfc4122UuidInterface;
@@ -564,14 +563,7 @@ class Uuid implements Rfc4122UuidInterface
*/
public static function uuid7(?DateTimeInterface $dateTime = null): UuidInterface
{
$factory = self::getFactory();
if (method_exists($factory, 'uuid7')) {
/** @var UuidInterface */
return $factory->uuid7($dateTime);
}
throw new UnsupportedOperationException('The provided factory does not support the uuid7() method');
return self::getFactory()->uuid7($dateTime);
}
/**
@@ -591,16 +583,6 @@ class Uuid implements Rfc4122UuidInterface
public static function uuid8(string $bytes): UuidInterface
{
/** @phpstan-ignore possiblyImpure.methodCall */
$factory = self::getFactory();
if (method_exists($factory, 'uuid8')) {
/**
* @var UuidInterface
* @phpstan-ignore possiblyImpure.methodCall
*/
return $factory->uuid8($bytes);
}
throw new UnsupportedOperationException('The provided factory does not support the uuid8() method');
return self::getFactory()->uuid8($bytes);
}
}
+2
View File
@@ -182,6 +182,8 @@ interface UuidFactoryInterface
*
* @return UuidInterface A UuidInterface instance that represents a
* version 8 UUID
*
* @pure
*/
public function uuid8(string $bytes): UuidInterface;
}
-15
View File
@@ -10,7 +10,6 @@ use Brick\Math\RoundingMode;
use DateTimeImmutable;
use DateTimeInterface;
use Mockery;
use Mockery\MockInterface;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\MockObject\MockObject;
use Ramsey\Uuid\Codec\StringCodec;
@@ -763,20 +762,6 @@ class UuidTest extends TestCase
$this->assertSame(Version::Custom, $uuid->getFields()->getVersion());
}
public function testUuid8ThrowsExceptionForUnsupportedFactory(): void
{
/** @var UuidFactoryInterface&MockInterface $factory */
$factory = Mockery::mock(UuidFactoryInterface::class);
Uuid::setFactory($factory);
$this->expectException(UnsupportedOperationException::class);
$this->expectExceptionMessage('The provided factory does not support the uuid8() method');
/** @phpstan-ignore staticMethod.resultUnused */
Uuid::uuid8("\x00\x11\x22\x33\x44\x55\x66\x77\x88\x99\xaa\xbb\xcc\xdd\xee\xff");
}
/**
* Tests known version-3 UUIDs
*