mirror of
https://github.com/ramsey/uuid.git
synced 2026-06-26 17:46:38 +03:00
feat: support version 8, custom UUIDs
This commit is contained in:
@@ -136,3 +136,23 @@ function v7(?DateTimeInterface $dateTime = null): string
|
||||
{
|
||||
return Uuid::uuid7($dateTime)->toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a version 8 (custom) UUID
|
||||
*
|
||||
* The bytes provided may contain any value according to your application's
|
||||
* needs. Be aware, however, that other applications may not understand the
|
||||
* semantics of the value.
|
||||
*
|
||||
* @param string $bytes A 16-byte octet string. This is an open blob
|
||||
* of data that you may fill with 128 bits of information. Be aware,
|
||||
* however, bits 48 through 51 will be replaced with the UUID version
|
||||
* field, and bits 64 and 65 will be replaced with the UUID variant. You
|
||||
* MUST NOT rely on these bits for your application needs.
|
||||
*
|
||||
* @return non-empty-string Version 7 UUID as a string
|
||||
*/
|
||||
function v8(string $bytes): string
|
||||
{
|
||||
return Uuid::uuid8($bytes)->toString();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user