Total Complexity | 11 |
Total Lines | 62 |
Duplicated Lines | 0 % |
Coverage | 0% |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
3 | class Nip_Form_Element_Hash extends Nip_Form_Element_Hidden |
||
4 | { |
||
5 | protected $_ID; |
||
6 | |||
7 | public function init() |
||
8 | { |
||
9 | parent::init(); |
||
10 | $this->initSession(); |
||
11 | } |
||
12 | |||
13 | public function initSession() |
||
14 | { |
||
15 | $name = $this->getSessionName(); |
||
16 | if (!$_SESSION[$name]) { |
||
17 | $this->reset(); |
||
18 | } |
||
19 | |||
20 | $this->setValue($this->getSessionValue()); |
||
21 | } |
||
22 | |||
23 | public function reset() |
||
24 | { |
||
25 | $name = $this->getSessionName(); |
||
26 | $hash = $this->_generateHash(); |
||
27 | $_SESSION[$name] = $hash; |
||
28 | $this->setValue($hash); |
||
29 | } |
||
30 | |||
31 | public function validate() |
||
32 | { |
||
33 | if (!$this->getValue()) { |
||
34 | $this->addError('Request received without security hash'); |
||
35 | } elseif ($this->getValue() != $this->getSessionValue()) { |
||
36 | $this->addError('Form security hash different from server'); |
||
37 | } |
||
38 | } |
||
39 | |||
40 | public function getSessionName() |
||
41 | { |
||
42 | return $this->getForm()->getName() . '_' . $this->getSalt(); |
||
43 | } |
||
44 | |||
45 | public function getSessionValue() |
||
46 | { |
||
47 | $name = $this->getSessionName(); |
||
48 | |||
49 | return $_SESSION[$name]; |
||
50 | } |
||
51 | |||
52 | public function getSalt() |
||
55 | } |
||
56 | |||
57 | protected function _generateHash() |
||
58 | { |
||
59 | return md5( |
||
65 | ); |
||
66 | } |
||
67 | } |
||
68 |
This check looks for function or method calls that always return null and whose return value is used.
The method
getObject()
can return nothing but null, so it makes no sense to use the return value.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.