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

UUID Utility. More...

+ Collaboration diagram for Sabre\DAV\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/) http://sabre.io/license/ Modified BSD License

Definition at line 16 of file UUIDUtil.php.

Member Function Documentation

◆ getUUID()

static Sabre\DAV\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 26 of file UUIDUtil.php.

Referenced by Sabre\CalDAV\Backend\Mock\__construct(), Sabre\CalDAV\Backend\Mock\createCalendar(), Sabre\DAV\Locks\Plugin\parseLockRequest(), Sabre\CalDAV\Schedule\Plugin\scheduleLocalDelivery(), and Sabre\CalDAV\Backend\PDO\updateInvites().

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

◆ validateUUID()

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

Checks if a string is a valid UUID.

Parameters
string$uuid
Returns
bool

Definition at line 55 of file UUIDUtil.php.

Referenced by Sabre\DAV\UUIDUtilTest\testValidateUUID().

55  {
56 
57  return preg_match(
58  '/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i',
59  $uuid
60  ) !== 0;
61 
62  }
+ Here is the caller graph for this function:

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