Dreamweaver   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 4
Bugs 0 Features 2
Metric Value
wmc 4
c 4
b 0
f 2
lcom 0
cbo 0
dl 0
loc 35
ccs 14
cts 14
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A encode_password() 0 9 2
A decode_password() 0 10 2
1
<?php
2
namespace Redbox\Dreamweaver;
3
4
class Dreamweaver
5
{
6
    /**
7
     * Encode a given password
8
     *
9
     * @param string $string
10
     * @return string
11
     */
12 4
    public static function encode_password($string = '') {
13 4
        $items = array();
14 4
        $len = strlen($string);
15 4
        for ($i = 0; $i < $len; $i++)
16
        {
17 4
            $items[] = dechex( ord($string[$i]) + $i ) ;
18 4
        }
19 4
        return strtoupper(implode('', $items));
20
    }
21
22
    /**
23
     * Decode a given password.
24
     *
25
     * @param string $encoded
26
     * @return string
27
     */
28 4
    public static function decode_password($encoded = '') {
29 4
        $literals = explode(' ', wordwrap($encoded, 2, ' ', 2));
30 4
        $length   = count($literals);
31 4
        $pass     = '';
32 4
33 4
        for ($i = 0; $i < $length; $i++) {
34
            $pass .= chr(hexdec($literals[$i]) - $i);
35 4
        }
36
        return $pass;
37
    }
38
}