-
Notifications
You must be signed in to change notification settings - Fork 51
Expand file tree
/
Copy pathUuidUtils.class.php
More file actions
56 lines (48 loc) · 1.43 KB
/
UuidUtils.class.php
File metadata and controls
56 lines (48 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
/***************************************************************************
* Copyright (C) 2012 by Georgiy T. Kutsurua *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation; either version 3 of the *
* License, or (at your option) any later version. *
* *
***************************************************************************/
/**
* @ingroup Utils
**/
class UuidUtils extends StaticFactory
{
const SEQUENCE_NAME = 'uuid';
/**
* @static
* @param $sequence
* @return bool
*/
public static function isUuidSequence($sequence)
{
return ($sequence === self::SEQUENCE_NAME);
}
/**
* @static
* @return bool
*/
public static function isExtensionLoaded()
{
return extension_loaded('uuid');
}
/**
* @static
* @param $type
* @return string
* @throws UnsupportedExtensionException
*/
public static function make($type=null)
{
if(!static::isExtensionLoaded() )
throw new UnsupportedExtensionException('uuid is unloaded, but it needed!');
if($type===null)
$type=UUID_TYPE_TIME;
return uuid_create($type);
}
}