ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Sabre\VObject\UUIDUtil Class Reference

UUID Utility. More...

+ Collaboration diagram for Sabre\VObject\UUIDUtil:

Static Public Member Functions

static getUUID ()
 Returns a pseudo-random v4 UUID. More...
 
static validateUUID ($uuid)
 Checks if a string is a valid UUID. More...
 

Detailed Description

UUID Utility.

This class has static methods to generate and validate UUID's. UUIDs are used a decent amount within various *DAV standards, so it made sense to include it.

Author
Evert Pot (http://evertpot.com/) @license http://sabre.io/license/ Modified BSD License

Definition at line 16 of file UUIDUtil.php.

Member Function Documentation

◆ getUUID()

static Sabre\VObject\UUIDUtil::getUUID ( )
static

Returns a pseudo-random v4 UUID.

This function is based on a comment by Andrew Moore on php.net

See also
http://www.php.net/manual/en/function.uniqid.php#94959
Returns
string

Definition at line 27 of file UUIDUtil.php.

27 {
28
29 return sprintf(
30
31 '%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
32
33 // 32 bits for "time_low"
34 mt_rand(0, 0xffff), mt_rand(0, 0xffff),
35
36 // 16 bits for "time_mid"
37 mt_rand(0, 0xffff),
38
39 // 16 bits for "time_hi_and_version",
40 // four most significant bits holds version number 4
41 mt_rand(0, 0x0fff) | 0x4000,
42
43 // 16 bits, 8 bits for "clk_seq_hi_res",
44 // 8 bits for "clk_seq_low",
45 // two most significant bits holds zero and one for variant DCE1.1
46 mt_rand(0, 0x3fff) | 0x8000,
47
48 // 48 bits for "node"
49 mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff)
50 );
51 }

Referenced by Sabre\VObject\Component\VCard\getDefaults(), Sabre\VObject\Component\VEvent\getDefaults(), Sabre\VObject\Component\VJournal\getDefaults(), Sabre\VObject\Component\VTodo\getDefaults(), Sabre\VObject\UUIDUtilTest\testGetUUID(), and Sabre\VObject\Component\VCard\validate().

+ Here is the caller graph for this function:

◆ validateUUID()

static Sabre\VObject\UUIDUtil::validateUUID (   $uuid)
static

Checks if a string is a valid UUID.

Parameters
string$uuid
Returns
bool

Definition at line 60 of file UUIDUtil.php.

60 {
61
62 return preg_match(
63 '/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i',
64 $uuid
65 ) !== 0;
66
67 }

Referenced by Sabre\VObject\UUIDUtilTest\testGetUUID(), and Sabre\VObject\UUIDUtilTest\testValidateUUID().

+ Here is the caller graph for this function:

The documentation for this class was generated from the following file: