File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed
Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -1017,6 +1017,18 @@ public static function uuid(): UuidInterface
10171017 return Uuid::uuid4 ();
10181018 }
10191019
1020+ /**
1021+ * Generate a UUID (version 7).
1022+ */
1023+ public static function uuidv7 (): UuidInterface
1024+ {
1025+ if (! class_exists (Uuid::class)) {
1026+ throw new RuntimeException ('The "ramsey/uuid" package is required to use the "uuidv7" method. Please run "composer require ramsey/uuid". ' );
1027+ }
1028+
1029+ return Uuid::uuid7 ();
1030+ }
1031+
10201032 /**
10211033 * Generate a time-ordered UUID.
10221034 */
Original file line number Diff line number Diff line change @@ -287,9 +287,15 @@ public function testUlid()
287287
288288 public function testUuid ()
289289 {
290+ // test uuidv4
290291 $ this ->assertInstanceOf (UuidInterface::class, $ uuid = Str::uuid ());
291292 $ this ->assertTrue (Str::isUuid ((string ) $ uuid ));
292293
294+ // test uuidv7
295+ $ this ->assertInstanceOf (UuidInterface::class, $ uuid = Str::uuidv7 ());
296+ $ this ->assertTrue (Str::isUuid ((string ) $ uuid ));
297+
298+ // test orderedUuid
293299 $ this ->assertInstanceOf (UuidInterface::class, $ uuid = Str::orderedUuid ());
294300 $ this ->assertTrue (Str::isUuid ((string ) $ uuid ));
295301 }
You can’t perform that action at this time.
0 commit comments