Conditions | 10 |
Paths | 16 |
Total Lines | 36 |
Code Lines | 21 |
Lines | 0 |
Ratio | 0 % |
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 |
||
17 | public function isMatching($getParamArray) |
||
18 | { |
||
19 | if (array_key_exists($this->getParamName(), $getParamArray)) { |
||
20 | $value = $getParamArray[$this->getParamName()]; |
||
21 | if (empty($value)) { |
||
22 | if ($this->getParamCondition() === self::PARAM_CONDITION_EMPTY) { |
||
23 | return true; |
||
24 | } |
||
25 | } else { |
||
26 | if ($this->getParamCondition() === self::PARAM_CONDITION_NOT_EMPTY) { |
||
27 | return true; |
||
28 | } |
||
29 | } |
||
30 | |||
31 | if ($value == $this->getParamValue()) { |
||
32 | if ($this->getParamCondition() === self::PARAM_CONDITION_EQUALS) { |
||
33 | return true; |
||
34 | } |
||
35 | } else { |
||
36 | if ($this->getParamCondition() === self::PARAM_CONDITION_NOT_EQUALS) { |
||
37 | return true; |
||
38 | } |
||
39 | } |
||
40 | |||
41 | if ($this->getParamCondition() === self::PARAM_CONDITION_EXISTS) { |
||
42 | return true; |
||
43 | } |
||
44 | |||
45 | } else { |
||
46 | if ($this->getParamCondition() === self::PARAM_CONDITION_MISSING) { |
||
47 | return true; |
||
48 | } |
||
49 | } |
||
50 | |||
51 | return false; |
||
52 | } |
||
53 | } |
||
54 |