1 | <?php |
||
19 | class PhPsst |
||
20 | { |
||
21 | /** |
||
22 | * @var Storage |
||
23 | */ |
||
24 | protected $storage; |
||
25 | |||
26 | /** |
||
27 | * @var string |
||
28 | */ |
||
29 | protected $cipher; |
||
30 | |||
31 | /** |
||
32 | * @const string |
||
33 | */ |
||
34 | const CIPHER_DEFAULT = 'AES-256-CBC'; |
||
35 | |||
36 | /** |
||
37 | * PhPsst constructor. |
||
38 | * @param Storage $storage |
||
39 | * @param string $cipher |
||
40 | */ |
||
41 | 5 | public function __construct(Storage $storage, $cipher = null) |
|
42 | { |
||
43 | 5 | $this->storage = $storage; |
|
44 | 5 | if ($cipher !== null) { |
|
45 | 1 | $this->cipher = $cipher; |
|
46 | 1 | } else { |
|
47 | 5 | $this->cipher = self::CIPHER_DEFAULT; |
|
48 | } |
||
49 | 5 | } |
|
50 | |||
51 | /** |
||
52 | * @param string $password |
||
53 | * @param int $ttl |
||
54 | * @param int $views |
||
55 | * @return string |
||
56 | */ |
||
57 | 9 | public function store($password, $ttl = 3600, $views = 1) |
|
81 | |||
82 | /** |
||
83 | * @param $secret |
||
84 | * @return string |
||
85 | */ |
||
86 | 6 | public function retrieve($secret) |
|
108 | |||
109 | /** |
||
110 | * @return string |
||
111 | */ |
||
112 | 3 | protected function generateKey() |
|
128 | } |
||
129 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.