@@ -27,6 +27,7 @@ class Uuid extends AbstractUid
2727 public const FORMAT_BASE_32 = 1 << 1 ;
2828 public const FORMAT_BASE_58 = 1 << 2 ;
2929 public const FORMAT_RFC_4122 = 1 << 3 ;
30+ public const FORMAT_RFC_9562 = self ::FORMAT_RFC_4122 ;
3031 public const FORMAT_ALL = -1 ;
3132
3233 protected const TYPE = 0 ;
@@ -50,7 +51,7 @@ public function __construct(string $uuid, bool $checkVariant = false)
5051
5152 public static function fromString (string $ uuid ): static
5253 {
53- $ uuid = self ::transformToRfc4122 ($ uuid
DD41
, self ::FORMAT_ALL );
54+ $ uuid = self ::transformToRfc9562 ($ uuid , self ::FORMAT_ALL );
5455
5556 if (__CLASS__ !== static ::class || 36 !== \strlen ($ uuid )) {
5657 return new static ($ uuid );
@@ -124,15 +125,15 @@ final public static function v8(string $uuid): UuidV8
124125 /**
125126 * @param int-mask-of<Uuid::FORMAT_*> $format
126127 */
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
128129 {
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 ;
130131
131- if (36 === \strlen ($ uuid ) && !($ format & self ::FORMAT_RFC_4122 )) {
132+ if (36 === \strlen ($ uuid ) && !($ format & self ::FORMAT_RFC_9562 )) {
132133 return false ;
133134 }
134135
135- if (false === $ uuid = self ::transformToRfc4122 ($ uuid , $ format )) {
136+ if (false === $ uuid = self ::transformToRfc9562 ($ uuid , $ format )) {
136137 return false ;
137138 }
138139
@@ -188,13 +189,13 @@ private static function format(string $uuid, string $version): string
188189 }
189190
190191 /**
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.
192193 *
193194 * @param int-mask-of<Uuid::FORMAT_*> $format
194195 *
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
196197 */
197- private static function transformToRfc4122 (string $ uuid , int $ format ): string |false
198+ private static function transformToRfc9562 (string $ uuid , int $ format ): string |false
198199 {
199200 $ inputUuid = $ uuid ;
200201 $ fromBase58 = false ;
@@ -217,7 +218,7 @@ private static function transformToRfc4122(string $uuid, int $format): string|fa
217218 $ uuid = $ ulid ->toRfc4122 ();
218219 }
219220
220- if ($ inputUuid === $ uuid && !($ format & self ::FORMAT_RFC_4122 )) {
221+ if ($ inputUuid === $ uuid && !($ format & self ::FORMAT_RFC_9562 )) {
221222 // input format doesn't match the input string
222223 return false ;
223224 }
0 commit comments