LazyUuidFromString for valid UUIDs in uppercase (#401)

This commit is contained in:
hubipe
2022-01-29 20:05:59 +01:00
committed by GitHub
parent 785bcf264d
commit e3e9179f27
2 changed files with 13 additions and 1 deletions
+2 -1
View File
@@ -476,10 +476,11 @@ class Uuid implements UuidInterface
*/
public static function fromString(string $uuid): UuidInterface
{
$uuid = strtolower($uuid);
if (! self::$factoryReplaced && preg_match(LazyUuidFromString::VALID_REGEX, $uuid) === 1) {
assert($uuid !== '');
return new LazyUuidFromString(strtolower($uuid));
return new LazyUuidFromString($uuid);
}
return self::getFactory()->fromString($uuid);
+11
View File
@@ -132,6 +132,17 @@ class UuidTest extends TestCase
Uuid::fromString('');
}
public function testFromStringUppercase(): void
{
$uuid = Uuid::fromString('FF6F8CB0-C57D-11E1-9B21-0800200C9A66');
$this->assertSame('ff6f8cb0-c57d-11e1-9b21-0800200c9a66', $uuid->toString());
}
public function testFromStringLazyUuidFromUppercase(): void
{
$this->assertInstanceOf(LazyUuidFromString::class, Uuid::fromString('FF6F8CB0-C57D-11E1-9B21-0800200C9A66'));
}
public function testGetBytes(): void
{
$uuid = Uuid::fromString('ff6f8cb0-c57d-11e1-9b21-0800200c9a66');