Utils::hexDump()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 15
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 1 Features 1
Metric Value
c 2
b 1
f 1
dl 0
loc 15
rs 9.4285
cc 3
eloc 9
nc 3
nop 1
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