Conditions | 10 |
Paths | 10 |
Total Lines | 35 |
Code Lines | 31 |
Lines | 0 |
Ratio | 0 % |
Tests | 31 |
CRAP Score | 10 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
32 | 176 | protected function addSaltString($data) |
|
33 | { |
||
34 | 176 | switch ($this->getSaltingMode()) { |
|
35 | 176 | case self::SALTING_MODE_APPEND: // passwordSALT |
|
1 ignored issue
–
show
|
|||
36 | 154 | $data .= $this->salt; |
|
37 | 154 | break; |
|
38 | 44 | case self::SALTING_MODE_PREPEND: // SALTpassword |
|
1 ignored issue
–
show
|
|||
39 | 44 | $data = $this->salt . $data; |
|
40 | 44 | break; |
|
41 | 22 | case self::SALTING_MODE_INFIX_INPUT: // SALTpasswordTLAS |
|
1 ignored issue
–
show
|
|||
42 | 22 | $data = $this->salt . $data . strrev($this->salt); |
|
43 | 22 | break; |
|
44 | 22 | case self::SALTING_MODE_INFIX_SALT: // passwordSALTdrowssap |
|
1 ignored issue
–
show
|
|||
45 | 22 | $data = $data . $this->salt . strrev($data); |
|
46 | 22 | break; |
|
47 | 22 | case self::SALTING_MODE_REVERSE_APPEND: // passwordTLAS |
|
1 ignored issue
–
show
|
|||
48 | 22 | $data .= strrev($this->salt); |
|
49 | 22 | break; |
|
50 | 22 | case self::SALTING_MODE_REVERSE_PREPEND: // TLASpassword |
|
1 ignored issue
–
show
|
|||
51 | 22 | $data = strrev($this->salt) . $data; |
|
52 | 22 | break; |
|
53 | 22 | case self::SALTING_MODE_DUPLICATE_SUFFIX: // passwordSALTTLAS |
|
1 ignored issue
–
show
|
|||
54 | 22 | $data = $data . $this->salt . strrev($this->salt); |
|
55 | 22 | break; |
|
56 | 22 | case self::SALTING_MODE_DUPLICATE_PREFIX: // SALTTLASpassword |
|
1 ignored issue
–
show
|
|||
57 | 22 | $data = $this->salt . strrev($this->salt) . $data; |
|
58 | 22 | break; |
|
59 | 22 | case self::SALTING_MODE_PALINDROME_MIRRORING: // SALTpassworddrowssapTLAS |
|
1 ignored issue
–
show
|
|||
60 | 22 | $data = $this->salt . $data . strrev($data) . strrev($this->salt); |
|
61 | 22 | break; |
|
62 | default: // case self::SALTING_MODE_NONE: |
||
63 | 22 | break; |
|
64 | } |
||
65 | |||
66 | 176 | return $data; |
|
67 | } |
||
138 |