Completed
Branch master (e562f1)
by Antony
02:11
created

Utils::createGuid()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 15
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 12
nc 2
nop 0
dl 0
loc 15
rs 9.8666
c 0
b 0
f 0
1
<?php
2
3
namespace AntonyThorpe\SilverShopUnleashed;
4
5
/**
6
 * Utility
7
 */
8
class Utils
9
{
10
    /**
11
     * Create a global unique id
12
     *
13
     * @return string Guid
14
     */
15
    public static function createGuid()
16
    {
17
        if (function_exists('com_create_guid') === true) {
18
            return trim(com_create_guid(), '{}');
19
        }
20
        return strtolower(sprintf(
21
            '%04X%04X-%04X-%04X-%04X-%04X%04X%04X',
22
            mt_rand(0, 65535),
23
            mt_rand(0, 65535),
24
            mt_rand(0, 65535),
25
            mt_rand(16384, 20479),
26
            mt_rand(32768, 49151),
27
            mt_rand(0, 65535),
28
            mt_rand(0, 65535),
29
            mt_rand(0, 65535)
30
        ));
31
    }
32
}
33