Completed
Push — master ( dbecc0...75f541 )
by Marcos
02:07 queued 02:01
created

Utils::GUID()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2.0625

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 3
cts 4
cp 0.75
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 0
crap 2.0625
1
<?php
2
/**
3
 * Nextcloud - passman
4
 *
5
 * This file is licensed under the Affero General Public License version 3 or
6
 * later. See the COPYING file.
7
 *
8
 * @author Sander Brand <[email protected]>
9
 * @copyright Sander Brand 2016
10
 */
11
12
namespace OCA\Passman\Utility;
13
14
class Utils {
15
    /**
16
     * Gets the unix epoch UTC timestamp
17
     * @return int
18
     */
19 2
	public static function getTime() {
20 2
		return (new \DateTime())->getTimestamp();
21
	}
22
	/**
23
	 * @return int the current unix time in milliseconds
24
	 */
25 1
	public static function getMicroTime() {
26 1
		return microtime(true);
27
	}
28
29
    /**
30
     * Generates a Globally Unique ID
31
     * @return string
32
     */
33 1
	public static function GUID() {
34 1
		if (function_exists('com_create_guid') === true)
35
		{
36
			return trim(com_create_guid(), '{}');
37
		}
38
39 1
		return sprintf('%04X%04X-%04X-%04X-%04X-%04X%04X%04X', mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(16384, 20479), mt_rand(32768, 49151), mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535));
40
	}
41
}