@@ -27,6 +27,7 @@ class Uuid extends AbstractUid
27
27
public const FORMAT_BASE_32 = 1 << 1 ;
28
28
public const FORMAT_BASE_58 = 1 << 2 ;
29
29
public const FORMAT_RFC_4122 = 1 << 3 ;
30
+ public const FORMAT_RFC_9562 = self ::FORMAT_RFC_4122 ;
30
31
public const FORMAT_ALL = -1 ;
31
32
32
33
protected const TYPE = 0 ;
@@ -50,7 +51,7 @@ public function __construct(string $uuid, bool $checkVariant = false)
50
51
51
52
public static function fromString (string $ uuid ): static
52
53
{
53
- $ uuid = self ::transformToRfc4122 ($ uuid , self ::FORMAT_ALL );
54
+ $ uuid = self ::transformToRfc9562 ($ uuid , self ::FORMAT_ALL );
54
55
55
56
if (__CLASS__ !== static ::class || 36 !== \strlen ($ uuid )) {
56
57
return new static ($ uuid );
@@ -124,15 +125,15 @@ final public static function v8(string $uuid): UuidV8
124
125
/**
125
126
* @param int-mask-of<Uuid::FORMAT_*> $format
126
127
*/
127
- public static function isValid (string $ uuid /* , int $format = self::FORMAT_RFC_4122 */ ): bool
128
+ public static function isValid (string $ uuid /* , int $format = self::FORMAT_RFC_9562 */ ): bool
128
129
{
129
- $ format = 1 < \func_num_args () ? func_get_arg (1 ) : self ::FORMAT_RFC_4122 ;
130
+ $ format = 1 < \func_num_args () ? func_get_arg (1 ) : self ::FORMAT_RFC_9562 ;
130
131
131
- if (36 === \strlen ($ uuid ) && !($ format & self ::FORMAT_RFC_4122 )) {
132
+ if (36 === \strlen ($ uuid ) && !($ format & self ::FORMAT_RFC_9562 )) {
132
133
return false ;
133
134
}
134
135
135
- if (false === $ uuid = self ::transformToRfc4122 ($ uuid , $ format )) {
136
+ if (false === $ uuid = self ::transformToRfc9562 ($ uuid , $ format )) {
136
137
return false ;
137
138
}
138
139
@@ -188,13 +189,13 @@ private static function format(string $uuid, string $version): string
188
189
}
189
190
190
191
/**
191
- * Transforms a binary string, a base-32 string or a base-58 string to a RFC4122 string.
192
+ * Transforms a binary string, a base-32 string or a base-58 string to a RFC9562 string.
192
193
*
193
194
* @param int-mask-of<Uuid::FORMAT_*> $format
194
195
*
195
- * @return string|false The RFC4122 string or false if the format doesn't match the input
196
+ * @return string|false The RFC9562 string or false if the format doesn't match the input
196
197
*/
197
- private static function transformToRfc4122 (string $ uuid , int $ format ): string |false
198
+ private static function transformToRfc9562 (string $ uuid , int $ format ): string |false
198
199
{
199
200
$ inputUuid = $ uuid ;
200
201
$ fromBase58 = false ;
@@ -217,7 +218,7 @@ private static function transformToRfc4122(string $uuid, int $format): string|fa
217
218
$ uuid = $ ulid ->toRfc4122 ();
218
219
}
219
220
220
- if ($ inputUuid === $ uuid && !($ format & self ::FORMAT_RFC_4122 )) {
221
+ if ($ inputUuid === $ uuid && !($ format & self ::FORMAT_RFC_9562 )) {
221
222
// input format doesn't match the input string
222
223
return false ;
223
224
}
0 commit comments