Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CONST ENCODE_BASE_64 = 1;
- CONST UUID_CLEAR_VER = 15;
- CONST UUID_VERSION_4 = 64;
- CONST UUID_CLEAR_VAR = 63;
- CONST UUID_VAR_RFC = 128;
- static function uuid(array $__options = [])
- {
- $__options +=
- [
- 'delimiter' => self::MINUS,
- 'before' => self::DEVOID,
- 'after' => self::DEVOID
- ];
- $uuid = static::random(0x10);
- $uuid[0x06] = chr(ord($uuid[0x06]) & static::UUID_CLEAR_VER | static::UUID_VERSION_4);
- $uuid[0x08] = chr(ord($uuid[0x08]) & static::UUID_CLEAR_VAR | static::UUID_VAR_RFC);
- return static::insert('{:before}{:value}{:after}', ['value' => static::join([
- bin2hex(static::sub($uuid, 0x00, 0x04)),
- bin2hex(static::sub($uuid, 0x04, 0x02)),
- bin2hex(static::sub($uuid, 0x06, 0x02)),
- bin2hex(static::sub($uuid, 0x08, 0x02)),
- bin2hex(static::sub($uuid, 0x0A, 0x06))], $__options['delimiter'])] + $__options);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement