Code Duplication    Length = 11-11 lines in 2 locations

classes/Hash.php 2 locations

@@ 74-84 (lines=11) @@
71
72
    public static function uuid($type=4, $namespace='', $name=''){
73
      switch($type){
74
        case 3: if(preg_match('/^\{?[0-9a-f]{8}\-?[0-9a-f]{4}\-?[0-9a-f]{4}\-?'.
75
        '[0-9a-f]{4}\-?[0-9a-f]{12}\}?$/Si', $namespace) !== 1) return false;
76
        $nhex = str_replace(array('-','{','}'), '', $namespace);
77
        $nstr = ''; for($i = 0; $i < strlen($nhex); $i+=2)
78
        $nstr .= chr(hexdec($nhex[$i].$nhex[$i+1]));
79
        $hash = md5($nstr . $name);
80
        return sprintf('%08s-%04s-%04x-%04x-%12s',
81
        substr($hash, 0, 8), substr($hash, 8, 4),
82
        (hexdec(substr($hash, 12, 4)) & 0x0fff) | 0x3000,
83
        (hexdec(substr($hash, 16, 4)) & 0x3fff) | 0x8000,
84
        substr($hash, 20, 12));
85
        case 5: if(preg_match('/^\{?[0-9a-f]{8}\-?[0-9a-f]{4}\-?[0-9a-f]{4}\-?'.
86
        '[0-9a-f]{4}\-?[0-9a-f]{12}\}?$/Si', $namespace) !== 1) return false;
87
        $nhex = str_replace(array('-','{','}'), '', $namespace);
@@ 85-95 (lines=11) @@
82
        (hexdec(substr($hash, 12, 4)) & 0x0fff) | 0x3000,
83
        (hexdec(substr($hash, 16, 4)) & 0x3fff) | 0x8000,
84
        substr($hash, 20, 12));
85
        case 5: if(preg_match('/^\{?[0-9a-f]{8}\-?[0-9a-f]{4}\-?[0-9a-f]{4}\-?'.
86
        '[0-9a-f]{4}\-?[0-9a-f]{12}\}?$/Si', $namespace) !== 1) return false;
87
        $nhex = str_replace(array('-','{','}'), '', $namespace);
88
        $nstr = ''; for($i = 0; $i < strlen($nhex); $i+=2)
89
        $nstr .= chr(hexdec($nhex[$i].$nhex[$i+1]));
90
        $hash = sha1($nstr . $name);
91
        return sprintf('%08s-%04s-%04x-%04x-%12s',
92
        substr($hash, 0, 8), substr($hash, 8, 4),
93
        (hexdec(substr($hash, 12, 4)) & 0x0fff) | 0x5000,
94
        (hexdec(substr($hash, 16, 4)) & 0x3fff) | 0x8000,
95
        substr($hash, 20, 12));
96
        default: case 4: return sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
97
        mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff),
98
        mt_rand(0, 0x0fff) | 0x4000, mt_rand(0, 0x3fff) | 0x8000,