ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
UUIDUtil.php
Go to the documentation of this file.
1<?php
2
3namespace Sabre\VObject;
4
16class UUIDUtil {
17
27 static function getUUID() {
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 }
52
60 static function validateUUID($uuid) {
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 }
68
69}
An exception for terminatinating execution or to throw for unit testing.
UUID Utility.
Definition: UUIDUtil.php:16
static validateUUID($uuid)
Checks if a string is a valid UUID.
Definition: UUIDUtil.php:60
static getUUID()
Returns a pseudo-random v4 UUID.
Definition: UUIDUtil.php:27