Utils::generateGuid()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Xls;
4
5
class Utils
6
{
7
    /**
8
     * returns hex representation of binary data
9
     * @param $data
10
     *
11
     * @return string
12
     */
13
    public static function hexDump($data)
14
    {
15
        $result = '';
16
17
        $charCount = strlen($data);
18
        for ($i = 0; $i < $charCount; $i++) {
19
            $byte = ord($data[$i]);
20
            if ($i > 0) {
21
                $result .= ' ';
22
            }
23
            $result .= sprintf('%02X', $byte);
24
        }
25
26
        return $result;
27
    }
28
29
    /**
30
     * @return string
31
     */
32
    public static function generateGuid()
33
    {
34
        return strtoupper(md5(uniqid(rand(), true)));
35
    }
36
}
37