GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

StringScrambler::getSalt()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
/**
3
 * StringScrambler.php
4
 *
5
 * @category        Naneau
6
 * @package         Obfuscator
7
 * @subpackage      Scrambler
8
 */
9
10
namespace Naneau\Obfuscator;
11
12
/**
13
 * StringScrambler
14
 *
15
 * Scrambles strings
16
 *
17
 * @category        Naneau
18
 * @package         Obfuscator
19
 * @subpackage      Scrambler
20
 */
21
class StringScrambler
22
{
23
    /**
24
     * Salt
25
     *
26
     * @return void
27
     **/
28
    private $salt;
29
30
    /**
31
     * Constructor
32
     *
33
     * @param  string $salt optional salt, when left empty (null) semi-random value will be generated
34
     * @return void
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
35
     **/
36
    public function __construct($salt = null)
37
    {
38
        if ($salt === null) {
39
            $this->setSalt(
40
                md5(microtime(true) . rand(0,1))
41
            );
42
        } else { 
43
            $this->setSalt($salt); 
44
        }
45
    }
46
47
    /**
48
     * Scramble a string
49
     *
50
     * @param  string $string
51
     * @return string
52
     **/
53
    public function scramble($string)
54
    {
55
        return 'p' . substr(md5($string . $this->getSalt()), 0, 6);
56
    }
57
58
    /**
59
     * Get the salt
60
     *
61
     * @return string
62
     */
63
    public function getSalt()
64
    {
65
        return $this->salt;
66
    }
67
68
    /**
69
     * Set the salt
70
     *
71
     * @param  string          $salt
72
     * @return StringScrambler
73
     */
74
    public function setSalt($salt)
75
    {
76
        $this->salt = $salt;
77
78
        return $this;
79
    }
80
}
81