Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9c24e5f

Browse files
committed
[Uid] Add AbstractUid::toString()
1 parent b7a3c21 commit 9c24e5f

File tree

4 files changed

+16
-0
lines changed

4 files changed

+16
-0
lines changed

src/Symfony/Component/Uid/AbstractUid.php

+5
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,11 @@ public function compare(self $other): int
164164
return (\strlen($this->uid) - \strlen($other->uid)) ?: ($this->uid <=> $other->uid);
165165
}
166166

167+
final public function toString(): string
168+
{
169+
return $this->__toString();
170+
}
171+
167172
public function __toString(): string
168173
{
169174
return $this->uid;

src/Symfony/Component/Uid/CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ CHANGELOG
55
---
66

77
* Add `UuidV1::toV6()`, `UuidV1::toV7()` and `UuidV6::toV7()`
8+
* Add `AbstractUid::toString()`
89

910
6.2
1011
---

src/Symfony/Component/Uid/Tests/UlidTest.php

+5
Original file line numberDiff line numberDiff line change
@@ -290,4 +290,9 @@ public function testNewMaxUlid()
290290
{
291291
$this->assertSame('7ZZZZZZZZZZZZZZZZZZZZZZZZZ', (string) new MaxUlid());
292292
}
293+
294+
public function testToString()
295+
{
296+
$this->assertSame('01HK77WP8T7107EZH9CNAES202', (new Ulid('01HK77WP8T7107EZH9CNAES202'))->toString());
297+
}
293298
}

src/Symfony/Component/Uid/Tests/UuidTest.php

+5
Original file line numberDiff line numberDiff line change
@@ -471,4 +471,9 @@ public function testV1ToV7WhenExtraTimeEntropyOverflows()
471471
$this->assertNotEquals($uuidV7, $sameUuidV7100NanosecondsLater);
472472
$this->assertSame(hexdec('0'.substr($uuidV7, -2)) + 1, hexdec('0'.substr($sameUuidV7100NanosecondsLater, -2)));
473473
}
474+
475+
public function testToString()
476+
{
477+
$this->assertSame('a45a8538-77a9-4335-bd30-236f59b81b81', (new UuidV4('a45a8538-77a9-4335-bd30-236f59b81b81'))->toString());
478+
}
474479
}

0 commit comments

Comments
 (0)