| Conditions | 75 |
| Paths | > 20000 |
| Total Lines | 226 |
| Code Lines | 161 |
| Lines | 156 |
| Ratio | 69.03 % |
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 |
||
| 23 | function widget( $args, $instance ) { |
||
|
|
|||
| 24 | extract( $args ); |
||
| 25 | |||
| 26 | $title = empty($instance['title']) ? '' : apply_filters('gd_features_widget_title', __($instance['title'], 'geodirectory')); |
||
| 27 | $icon_color = $instance['icon_color']; |
||
| 28 | |||
| 29 | $title1 = $instance['title1']; |
||
| 30 | $title2 = $instance['title2']; |
||
| 31 | $title3 = $instance['title3']; |
||
| 32 | $title4 = $instance['title4']; |
||
| 33 | $title5 = $instance['title5']; |
||
| 34 | $title6 = $instance['title6']; |
||
| 35 | $title7 = $instance['title7']; |
||
| 36 | $title8 = $instance['title8']; |
||
| 37 | $title9 = $instance['title9']; |
||
| 38 | $title10 = $instance['title10']; |
||
| 39 | $title11 = $instance['title11']; |
||
| 40 | $title12 = $instance['title12']; |
||
| 41 | |||
| 42 | $image1 = $instance['image1']; |
||
| 43 | $image2 = $instance['image2']; |
||
| 44 | $image3 = $instance['image3']; |
||
| 45 | $image4 = $instance['image4']; |
||
| 46 | $image5 = $instance['image5']; |
||
| 47 | $image6 = $instance['image6']; |
||
| 48 | $image7 = $instance['image7']; |
||
| 49 | $image8 = $instance['image8']; |
||
| 50 | $image9 = $instance['image9']; |
||
| 51 | $image10 = $instance['image10']; |
||
| 52 | $image11 = $instance['image11']; |
||
| 53 | $image12 = $instance['image12']; |
||
| 54 | |||
| 55 | $desc1 = $instance['desc1']; |
||
| 56 | $desc2 = $instance['desc2']; |
||
| 57 | $desc3 = $instance['desc3']; |
||
| 58 | $desc4 = $instance['desc4']; |
||
| 59 | $desc5 = $instance['desc5']; |
||
| 60 | $desc6 = $instance['desc6']; |
||
| 61 | $desc7 = $instance['desc7']; |
||
| 62 | $desc8 = $instance['desc8']; |
||
| 63 | $desc9 = $instance['desc9']; |
||
| 64 | $desc10 = $instance['desc10']; |
||
| 65 | $desc11 = $instance['desc11']; |
||
| 66 | $desc12 = $instance['desc12']; |
||
| 67 | |||
| 68 | echo $before_widget; |
||
| 69 | ?> |
||
| 70 | <?php if ($title) { |
||
| 71 | echo '<div class="geodir_list_heading clearfix">'; |
||
| 72 | echo $before_title . $title . $after_title; |
||
| 73 | echo '</div>'; |
||
| 74 | } ?> |
||
| 75 | <?php |
||
| 76 | echo "<ul class='gd-features'>"; |
||
| 77 | View Code Duplication | if ($title1 OR $image1 OR $desc1) { |
|
|
1 ignored issue
–
show
|
|||
| 78 | echo "<li>"; |
||
| 79 | if ($title1) { |
||
| 80 | echo "<h3 class='gd-fe-title'>" . $title1 . "</h3>"; |
||
| 81 | } |
||
| 82 | if ($image1) { |
||
| 83 | echo "<div class='gd-fe-image'>" . gd_features_parse_image($image1, $icon_color) . "</div>"; |
||
| 84 | } |
||
| 85 | if ($desc1) { |
||
| 86 | echo "<div class='gd-fe-desc'>" . gd_features_parse_desc($desc1) . "</div>"; |
||
| 87 | } |
||
| 88 | echo "</li>"; |
||
| 89 | } |
||
| 90 | |||
| 91 | View Code Duplication | if ($title2 OR $image2 OR $desc2) { |
|
|
1 ignored issue
–
show
|
|||
| 92 | echo "<li>"; |
||
| 93 | if ($title2) { |
||
| 94 | echo "<h3 class='gd-fe-title'>" . $title2 . "</h3>"; |
||
| 95 | } |
||
| 96 | if ($image2) { |
||
| 97 | echo "<div class='gd-fe-image'>" . gd_features_parse_image($image2, $icon_color) . "</div>"; |
||
| 98 | } |
||
| 99 | if ($desc2) { |
||
| 100 | echo "<div class='gd-fe-desc'>" . gd_features_parse_desc($desc2) . "</div>"; |
||
| 101 | } |
||
| 102 | echo "</li>"; |
||
| 103 | } |
||
| 104 | |||
| 105 | View Code Duplication | if ($title3 OR $image3 OR $desc3) { |
|
|
1 ignored issue
–
show
|
|||
| 106 | echo "<li>"; |
||
| 107 | if ($title3) { |
||
| 108 | echo "<h3 class='gd-fe-title'>" . $title3 . "</h3>"; |
||
| 109 | } |
||
| 110 | if ($image3) { |
||
| 111 | echo "<div class='gd-fe-image'>" . gd_features_parse_image($image3, $icon_color) . "</div>"; |
||
| 112 | } |
||
| 113 | if ($desc3) { |
||
| 114 | echo "<div class='gd-fe-desc'>" . gd_features_parse_desc($desc3) . "</div>"; |
||
| 115 | } |
||
| 116 | echo "</li>"; |
||
| 117 | } |
||
| 118 | |||
| 119 | View Code Duplication | if ($title4 OR $image4 OR $desc4) { |
|
|
1 ignored issue
–
show
|
|||
| 120 | echo "<li>"; |
||
| 121 | if ($title4) { |
||
| 122 | echo "<h3 class='gd-fe-title'>" . $title4 . "</h3>"; |
||
| 123 | } |
||
| 124 | if ($image4) { |
||
| 125 | echo "<div class='gd-fe-image'>" . gd_features_parse_image($image4, $icon_color) . "</div>"; |
||
| 126 | } |
||
| 127 | if ($desc4) { |
||
| 128 | echo "<div class='gd-fe-desc'>" . gd_features_parse_desc($desc4) . "</div>"; |
||
| 129 | } |
||
| 130 | echo "</li>"; |
||
| 131 | } |
||
| 132 | |||
| 133 | View Code Duplication | if ($title5 OR $image5 OR $desc5) { |
|
|
1 ignored issue
–
show
|
|||
| 134 | echo "<li>"; |
||
| 135 | if ($title5) { |
||
| 136 | echo "<h3 class='gd-fe-title'>" . $title5 . "</h3>"; |
||
| 137 | } |
||
| 138 | if ($image5) { |
||
| 139 | echo "<div class='gd-fe-image'>" . gd_features_parse_image($image5, $icon_color) . "</div>"; |
||
| 140 | } |
||
| 141 | if ($desc5) { |
||
| 142 | echo "<div class='gd-fe-desc'>" . gd_features_parse_desc($desc5) . "</div>"; |
||
| 143 | } |
||
| 144 | echo "</li>"; |
||
| 145 | } |
||
| 146 | |||
| 147 | View Code Duplication | if ($title6 OR $image6 OR $desc6) { |
|
|
1 ignored issue
–
show
|
|||
| 148 | echo "<li>"; |
||
| 149 | if ($title6) { |
||
| 150 | echo "<h3 class='gd-fe-title'>" . $title6 . "</h3>"; |
||
| 151 | } |
||
| 152 | if ($image6) { |
||
| 153 | echo "<div class='gd-fe-image'>" . gd_features_parse_image($image6, $icon_color) . "</div>"; |
||
| 154 | } |
||
| 155 | if ($desc6) { |
||
| 156 | echo "<div class='gd-fe-desc'>" . gd_features_parse_desc($desc6) . "</div>"; |
||
| 157 | } |
||
| 158 | echo "</li>"; |
||
| 159 | } |
||
| 160 | |||
| 161 | View Code Duplication | if ($title7 OR $image7 OR $desc7) { |
|
|
1 ignored issue
–
show
|
|||
| 162 | echo "<li>"; |
||
| 163 | if ($title7) { |
||
| 164 | echo "<h3 class='gd-fe-title'>" . $title7 . "</h3>"; |
||
| 165 | } |
||
| 166 | if ($image7) { |
||
| 167 | echo "<div class='gd-fe-image'>" . gd_features_parse_image($image7, $icon_color) . "</div>"; |
||
| 168 | } |
||
| 169 | if ($desc7) { |
||
| 170 | echo "<div class='gd-fe-desc'>" . gd_features_parse_desc($desc7) . "</div>"; |
||
| 171 | } |
||
| 172 | echo "</li>"; |
||
| 173 | } |
||
| 174 | |||
| 175 | View Code Duplication | if ($title8 OR $image8 OR $desc8) { |
|
|
1 ignored issue
–
show
|
|||
| 176 | echo "<li>"; |
||
| 177 | if ($title8) { |
||
| 178 | echo "<h3 class='gd-fe-title'>" . $title8 . "</h3>"; |
||
| 179 | } |
||
| 180 | if ($image8) { |
||
| 181 | echo "<div class='gd-fe-image'>" . gd_features_parse_image($image8, $icon_color) . "</div>"; |
||
| 182 | } |
||
| 183 | if ($desc8) { |
||
| 184 | echo "<div class='gd-fe-desc'>" . gd_features_parse_desc($desc8) . "</div>"; |
||
| 185 | } |
||
| 186 | echo "</li>"; |
||
| 187 | } |
||
| 188 | |||
| 189 | View Code Duplication | if ($title9 OR $image9 OR $desc9) { |
|
|
1 ignored issue
–
show
|
|||
| 190 | echo "<li>"; |
||
| 191 | if ($title9) { |
||
| 192 | echo "<h3 class='gd-fe-title'>" . $title9 . "</h3>"; |
||
| 193 | } |
||
| 194 | if ($image9) { |
||
| 195 | echo "<div class='gd-fe-image'>" . gd_features_parse_image($image9, $icon_color) . "</div>"; |
||
| 196 | } |
||
| 197 | if ($desc9) { |
||
| 198 | echo "<div class='gd-fe-desc'>" . gd_features_parse_desc($desc9) . "</div>"; |
||
| 199 | } |
||
| 200 | echo "</li>"; |
||
| 201 | } |
||
| 202 | |||
| 203 | View Code Duplication | if ($title10 OR $image10 OR $desc10) { |
|
|
1 ignored issue
–
show
|
|||
| 204 | echo "<li>"; |
||
| 205 | if ($title10) { |
||
| 206 | echo "<h3 class='gd-fe-title'>" . $title10 . "</h3>"; |
||
| 207 | } |
||
| 208 | if ($image10) { |
||
| 209 | echo "<div class='gd-fe-image'>" . gd_features_parse_image($image10, $icon_color) . "</div>"; |
||
| 210 | } |
||
| 211 | if ($desc10) { |
||
| 212 | echo "<div class='gd-fe-desc'>" . gd_features_parse_desc($desc10) . "</div>"; |
||
| 213 | } |
||
| 214 | echo "</li>"; |
||
| 215 | } |
||
| 216 | |||
| 217 | View Code Duplication | if ($title11 OR $image11 OR $desc11) { |
|
|
1 ignored issue
–
show
|
|||
| 218 | echo "<li>"; |
||
| 219 | if ($title11) { |
||
| 220 | echo "<h3 class='gd-fe-title'>" . $title11 . "</h3>"; |
||
| 221 | } |
||
| 222 | if ($image11) { |
||
| 223 | echo "<div class='gd-fe-image'>" . gd_features_parse_image($image11, $icon_color) . "</div>"; |
||
| 224 | } |
||
| 225 | if ($desc11) { |
||
| 226 | echo "<div class='gd-fe-desc'>" . gd_features_parse_desc($desc11) . "</div>"; |
||
| 227 | } |
||
| 228 | echo "</li>"; |
||
| 229 | } |
||
| 230 | |||
| 231 | View Code Duplication | if ($title12 OR $image12 OR $desc12) { |
|
|
1 ignored issue
–
show
|
|||
| 232 | echo "<li>"; |
||
| 233 | if ($title12) { |
||
| 234 | echo "<h3 class='gd-fe-title'>" . $title12 . "</h3>"; |
||
| 235 | } |
||
| 236 | if ($image12) { |
||
| 237 | echo "<div class='gd-fe-image'>" . gd_features_parse_image($image12, $icon_color) . "</div>"; |
||
| 238 | } |
||
| 239 | if ($desc12) { |
||
| 240 | echo "<div class='gd-fe-desc'>" . gd_features_parse_desc($desc12) . "</div>"; |
||
| 241 | } |
||
| 242 | echo "</li>"; |
||
| 243 | } |
||
| 244 | echo "</ul>"; |
||
| 245 | ?> |
||
| 246 | <?php echo $after_widget; ?> |
||
| 247 | <?php |
||
| 248 | } |
||
| 249 | |||
| 600 | } |
Adding explicit visibility (
private,protected, orpublic) is generally recommend to communicate to other developers how, and from where this method is intended to be used.