File tree Expand file tree Collapse file tree 3 files changed +19
-3
lines changed
Expand file tree Collapse file tree 3 files changed +19
-3
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 @@ -57,10 +57,8 @@ public function __get($key)
5757
5858 /**
5959 * Get the raw string value.
60- *
61- * @return string
6260 */
63- public function __toString ()
61+ public function __toString (): string
6462 {
6563 return $ this ->value ;
6664 }
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