Skip to content

Commit e6188a0

Browse files
committed
Merge branch 'master' into 3.2-merge
2 parents dc2c844 + 31a4686 commit e6188a0

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

src/Str.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff 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
*/

src/Stringable.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff 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
}

tests/StrTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff 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
}

0 commit comments

Comments
 (0)