| Conditions | 7 |
| Paths | 64 |
| Total Lines | 112 |
| Code Lines | 92 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | 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 |
||
| 215 | public function get_menu_items(){ |
||
| 216 | $items = array(); |
||
| 217 | |||
| 218 | $wpinv_history_page_id = (int)wpinv_get_option( 'invoice_history_page' ); |
||
| 219 | if($wpinv_history_page_id > 0){ |
||
| 220 | $item = new stdClass(); |
||
| 221 | $item->object_id = $wpinv_history_page_id; |
||
| 222 | $item->db_id = 0; |
||
| 223 | $item->object = 'page'; |
||
| 224 | $item->menu_item_parent = 0; |
||
| 225 | $item->type = 'post_type'; |
||
| 226 | $item->title = __('Invoice History Page','invoicing'); |
||
| 227 | $item->url = get_permalink( $wpinv_history_page_id ); |
||
| 228 | $item->target = ''; |
||
| 229 | $item->attr_title = ''; |
||
| 230 | $item->classes = array('wpinv-menu-item'); |
||
| 231 | $item->xfn = ''; |
||
| 232 | |||
| 233 | $items['pages'][] = $item; |
||
| 234 | } |
||
| 235 | |||
| 236 | $wpinv_sub_history_page_id = (int)wpinv_get_option( 'invoice_subscription_page' ); |
||
| 237 | if($wpinv_sub_history_page_id > 0){ |
||
| 238 | $item = new stdClass(); |
||
| 239 | $item->object_id = $wpinv_sub_history_page_id; |
||
| 240 | $item->db_id = 0; |
||
| 241 | $item->object = 'page'; |
||
| 242 | $item->menu_item_parent = 0; |
||
| 243 | $item->type = 'post_type'; |
||
| 244 | $item->title = __('Invoice Subscriptions Page','invoicing'); |
||
| 245 | $item->url = get_permalink( $wpinv_sub_history_page_id ); |
||
| 246 | $item->target = ''; |
||
| 247 | $item->attr_title = ''; |
||
| 248 | $item->classes = array('wpinv-menu-item'); |
||
| 249 | $item->xfn = ''; |
||
| 250 | |||
| 251 | $items['pages'][] = $item; |
||
| 252 | } |
||
| 253 | |||
| 254 | $wpinv_checkout_page_id = (int)wpinv_get_option( 'checkout_page' ); |
||
| 255 | if($wpinv_checkout_page_id > 0){ |
||
| 256 | $item = new stdClass(); |
||
| 257 | $item->object_id = $wpinv_checkout_page_id; |
||
| 258 | $item->db_id = 0; |
||
| 259 | $item->object = 'page'; |
||
| 260 | $item->menu_item_parent = 0; |
||
| 261 | $item->type = 'post_type'; |
||
| 262 | $item->title = __('Checkout Page','invoicing'); |
||
| 263 | $item->url = get_permalink( $wpinv_checkout_page_id ); |
||
| 264 | $item->target = ''; |
||
| 265 | $item->attr_title = ''; |
||
| 266 | $item->classes = array('wpinv-menu-item'); |
||
| 267 | $item->xfn = ''; |
||
| 268 | |||
| 269 | $items['pages'][] = $item; |
||
| 270 | } |
||
| 271 | |||
| 272 | $wpinv_tandc_page_id = (int)wpinv_get_option( 'tandc_page' ); |
||
| 273 | if($wpinv_tandc_page_id > 0){ |
||
| 274 | $item = new stdClass(); |
||
| 275 | $item->object_id = $wpinv_tandc_page_id; |
||
| 276 | $item->db_id = 0; |
||
| 277 | $item->object = 'page'; |
||
| 278 | $item->menu_item_parent = 0; |
||
| 279 | $item->type = 'post_type'; |
||
| 280 | $item->title = __('Terms & Conditions','invoicing'); |
||
| 281 | $item->url = get_permalink( $wpinv_tandc_page_id ); |
||
| 282 | $item->target = ''; |
||
| 283 | $item->attr_title = ''; |
||
| 284 | $item->classes = array('wpinv-menu-item'); |
||
| 285 | $item->xfn = ''; |
||
| 286 | |||
| 287 | $items['pages'][] = $item; |
||
| 288 | } |
||
| 289 | |||
| 290 | $wpinv_success_page_id = (int)wpinv_get_option( 'success_page' ); |
||
| 291 | if($wpinv_success_page_id > 0){ |
||
| 292 | $item = new stdClass(); |
||
| 293 | $item->object_id = $wpinv_success_page_id; |
||
| 294 | $item->db_id = 0; |
||
| 295 | $item->object = 'page'; |
||
| 296 | $item->menu_item_parent = 0; |
||
| 297 | $item->type = 'post_type'; |
||
| 298 | $item->title = __('Success Page','invoicing'); |
||
| 299 | $item->url = get_permalink( $wpinv_success_page_id ); |
||
| 300 | $item->target = ''; |
||
| 301 | $item->attr_title = ''; |
||
| 302 | $item->classes = array('wpinv-menu-item'); |
||
| 303 | $item->xfn = ''; |
||
| 304 | |||
| 305 | $items['pages'][] = $item; |
||
| 306 | } |
||
| 307 | |||
| 308 | $wpinv_failure_page_id = (int)wpinv_get_option( 'failure_page' ); |
||
| 309 | if($wpinv_failure_page_id > 0){ |
||
| 310 | $item = new stdClass(); |
||
| 311 | $item->object_id = $wpinv_failure_page_id; |
||
| 312 | $item->db_id = 0; |
||
| 313 | $item->object = 'page'; |
||
| 314 | $item->menu_item_parent = 0; |
||
| 315 | $item->type = 'post_type'; |
||
| 316 | $item->title = __('Failed Transaction Page','invoicing'); |
||
| 317 | $item->url = get_permalink( $wpinv_failure_page_id ); |
||
| 318 | $item->target = ''; |
||
| 319 | $item->attr_title = ''; |
||
| 320 | $item->classes = array('wpinv-menu-item'); |
||
| 321 | $item->xfn = ''; |
||
| 322 | |||
| 323 | $items['pages'][] = $item; |
||
| 324 | } |
||
| 325 | |||
| 326 | return apply_filters( 'wpinv_menu_items', $items ); |
||
| 327 | } |
||
| 331 | return new WPInv_Admin_Menus(); |