| Conditions | 11 |
| Paths | 6 |
| Total Lines | 16 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 3 | ||
| 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 |
||
| 72 | public function validate($value) |
||
| 73 | { |
||
| 74 | if ($this->hashAlgorithm == self::ALGO_MD5 && $this->validateHexString($value, 32)) { |
||
| 75 | return true; |
||
| 76 | } elseif ($this->hashAlgorithm == self::ALGO_SHA1 && $this->validateHexString($value, 40)) { |
||
| 77 | return true; |
||
| 78 | } elseif ($this->hashAlgorithm == self::ALGO_SHA256 && $this->validateHexString($value, 64)) { |
||
| 79 | return true; |
||
| 80 | } elseif ($this->hashAlgorithm == self::ALGO_SHA512 && $this->validateHexString($value, 128)) { |
||
| 81 | return true; |
||
| 82 | } elseif ($this->hashAlgorithm == self::ALGO_CRC32 && $this->validateHexString($value, 8)) { |
||
| 83 | return true; |
||
| 84 | } |
||
| 85 | |||
| 86 | return $this->error(self::INVALID_FORMAT); |
||
| 87 | } |
||
| 88 | |||
| 102 |