Skip to content

Commit 605adbf

Browse files
Implemented UUIDv6 factory and getTypecast
1 parent 163bed8 commit 605adbf

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

‎src/Uuid6.php‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor;
1010
use JetBrains\PhpStorm\ArrayShape;
1111
use Ramsey\Identifier\Service\Nic\Nic;
12+
use Ramsey\Identifier\Uuid\UuidV6;
13+
use Ramsey\Identifier\Uuid\UuidV6Factory;
1214

1315
/**
1416
* Uses a version 6 (ordered-time) UUID from a host ID, sequence number,
@@ -54,6 +56,22 @@ public function __construct(
5456
$this->clockSeq = $clockSeq;
5557
}
5658

59+
/**
60+
* Create a new UUIDv6 instance from an existing identifier value.
61+
*
62+
* @param non-empty-string $identifier The identifier to create the Uuid from
63+
*/
64+
public static function create(string $identifier): UuidV6
65+
{
66+
return (new UuidV6Factory())->createFromString($identifier);
67+
}
68+
69+
#[\Override]
70+
protected function getTypecast(): array
71+
{
72+
return [self::class, 'create'];
73+
}
74+
5775
#[\Override]
5876
protected function getListenerClass(): string
5977
{

0 commit comments

Comments
 (0)