Conditions | 13 |
Paths | 11 |
Total Lines | 32 |
Code Lines | 16 |
Lines | 0 |
Ratio | 0 % |
Tests | 19 |
CRAP Score | 13 |
Changes | 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 |
||
46 | 6 | protected function isMatching(array $break_data, array $rules) |
|
47 | { |
||
48 | 6 | if ( !$rules ) { |
|
49 | 1 | return false; |
|
50 | } |
||
51 | |||
52 | 5 | foreach ( $rules as $rule_data ) { |
|
53 | 5 | if ( isset($rule_data['type']) && $rule_data['type'] !== $break_data['type'] ) { |
|
54 | 4 | continue; |
|
55 | } |
||
56 | |||
57 | 5 | if ( isset($rule_data['element']) && $rule_data['element'] !== $break_data['element'] ) { |
|
58 | 4 | continue; |
|
59 | } |
||
60 | |||
61 | 5 | if ( isset($rule_data['old']) ) { |
|
62 | 2 | if ( !isset($break_data['old']) || $rule_data['old'] !== $break_data['old'] ) { |
|
63 | 2 | continue; |
|
64 | } |
||
65 | 2 | } |
|
66 | |||
67 | 5 | if ( isset($rule_data['new']) ) { |
|
68 | 2 | if ( !isset($break_data['new']) || $rule_data['new'] !== $break_data['new'] ) { |
|
69 | 1 | continue; |
|
70 | } |
||
71 | 1 | } |
|
72 | |||
73 | 4 | return true; |
|
74 | 5 | } |
|
75 | |||
76 | 5 | return false; |
|
77 | } |
||
78 | |||
80 |