Hash::generateHash()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 15
rs 9.7666
c 0
b 0
f 0
cc 2
nc 2
nop 1
1
<?php
2
3
/**
4
 * Hash
5
 * @copyright Copyright (c) 2011 - 2014 Aleksandr Torosh (http://wezoom.com.ua)
6
 * @author Aleksandr Torosh <[email protected]>
7
 */
8
namespace Application\Utils;
9
10
class Hash
11
{
12
13
    public static function generateHash($length = 12)
14
    {
15
        $list = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890';
16
        $len = mb_strlen($list, 'utf-8');
17
18
        $result = '';
19
        for ($i = 1; $i <= $length; $i++) {
20
            $element = rand(0, $len - 1);
21
            $char = $list[$element];
22
            $result .= $char;
23
        }
24
25
        return $result;
26
27
    }
28
29
}
30