Conditions | 10 |
Paths | 24 |
Total Lines | 48 |
Code Lines | 31 |
Lines | 48 |
Ratio | 100 % |
Changes | 3 | ||
Bugs | 2 | Features | 1 |
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 |
||
78 | View Code Duplication | function prepData($email, $bounce_type, $remove) |
|
79 | { |
||
80 | $data['bounce_type'] = trim($bounce_type); |
||
81 | $data['email'] = ''; |
||
82 | $data['emailName'] = ''; |
||
83 | $data['emailAddy'] = ''; |
||
84 | $data['remove'] = ''; |
||
85 | if (strpos($email, '<') !== false) { |
||
86 | $pos_start = strpos($email, '<'); |
||
87 | $data['emailName'] = trim(substr($email, 0, $pos_start)); |
||
88 | $data['emailAddy'] = substr($email, $pos_start + 1); |
||
89 | $pos_end = strpos($data['emailAddy'], '>'); |
||
90 | if ($pos_end) { |
||
91 | $data['emailAddy'] = substr($data['emailAddy'], 0, $pos_end); |
||
92 | } |
||
93 | } |
||
94 | |||
95 | // replace the < and > able so they display on screen |
||
96 | // replace the < and > able so they display on screen |
||
97 | $email = str_replace(array('<', '>'), array('<', '>'), $email); |
||
98 | |||
99 | // replace the "TO:<" with nothing |
||
100 | $email = str_ireplace('TO:<', '', $email); |
||
101 | |||
102 | $data['email'] = $email; |
||
103 | |||
104 | // account for legitimate emails that have no bounce type |
||
105 | if (trim($bounce_type) == '') { |
||
106 | $data['bounce_type'] = 'none'; |
||
107 | } |
||
108 | |||
109 | // change the remove flag from true or 1 to textual representation |
||
110 | if (stripos($remove, 'moved') !== false && stripos($remove, 'hard') !== false) { |
||
111 | $data['removestat'] = 'moved (hard)'; |
||
112 | $data['remove'] = '<span style="color:red;">' . 'moved (hard)' . '</span>'; |
||
113 | } elseif (stripos($remove, 'moved') !== false && stripos($remove, 'soft') !== false) { |
||
114 | $data['removestat'] = 'moved (soft)'; |
||
115 | $data['remove'] = '<span style="color:gray;">' . 'moved (soft)' . '</span>'; |
||
116 | } elseif ($remove == true || $remove == '1') { |
||
117 | $data['removestat'] = 'deleted'; |
||
118 | $data['remove'] = '<span style="color:red;">' . 'deleted' . '</span>'; |
||
119 | } else { |
||
120 | $data['removestat'] = 'not deleted'; |
||
121 | $data['remove'] = '<span style="color:gray;">' . 'not deleted' . '</span>'; |
||
122 | } |
||
123 | |||
124 | return $data; |
||
125 | } |
||
126 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.