mirror of
https://github.com/ramsey/uuid.git
synced 2026-06-13 15:46:53 +03:00
LazyUuidFromString for valid UUIDs in uppercase (#401)
This commit is contained in:
+2
-1
@@ -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);
|
||||
|
||||
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user