| Conditions | 11 |
| Paths | 108 |
| Total Lines | 68 |
| Code Lines | 24 |
| 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 |
||
| 43 | public static function add_meta_boxes( $post_type, $post ) { |
||
| 44 | global $wpinv_euvat; |
||
| 45 | |||
| 46 | // For invoices... |
||
| 47 | if ( $post_type == 'wpi_invoice' ) { |
||
| 48 | $invoice = new WPInv_Invoice( $post ); |
||
| 49 | |||
| 50 | // Resend invoice. |
||
| 51 | if ( ! $invoice->is_draft() ) { |
||
| 52 | add_meta_box( 'wpinv-mb-resend-invoice', __( 'Resend Invoice', 'invoicing' ), 'GetPaid_Meta_Box_Resend_Invoice::output', 'wpi_invoice', 'side', 'high' ); |
||
| 53 | } |
||
| 54 | |||
| 55 | // Subscriptions. |
||
| 56 | if ( $invoice->is_recurring() ) { |
||
| 57 | add_meta_box( 'wpinv-mb-subscriptions', __( 'Subscription Details', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Subscription::output', 'wpi_invoice', 'side', 'high' ); |
||
| 58 | } |
||
| 59 | |||
| 60 | // Invoice details. |
||
| 61 | add_meta_box( 'wpinv-details', __( 'Invoice Details', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Details::output', 'wpi_invoice', 'side', 'default' ); |
||
| 62 | |||
| 63 | // Payment details. |
||
| 64 | add_meta_box( 'wpinv-payment-meta', __( 'Payment Meta', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Payment_Meta::output', 'wpi_invoice', 'side', 'default' ); |
||
| 65 | |||
| 66 | // Billing details. |
||
| 67 | add_meta_box( 'wpinv-address', __( 'Billing Details', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Address::output', 'wpi_invoice', 'normal', 'high' ); |
||
| 68 | |||
| 69 | // Invoice items. |
||
| 70 | add_meta_box( 'wpinv-items', __( 'Invoice Items', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Items::output', 'wpi_invoice', 'normal', 'high' ); |
||
| 71 | |||
| 72 | // Invoice notes. |
||
| 73 | add_meta_box( 'wpinv-notes', __( 'Invoice Notes', 'invoicing' ), 'WPInv_Meta_Box_Notes::output', 'wpi_invoice', 'normal', 'high' ); |
||
| 74 | |||
| 75 | // Payment form information. |
||
| 76 | if ( ! empty( $post->ID ) && get_post_meta( $post->ID, 'payment_form_data', true ) ) { |
||
| 77 | add_meta_box( 'wpinv-invoice-payment-form-details', __( 'Payment Form Details', 'invoicing' ), 'WPInv_Meta_Box_Payment_Form::output_details', 'wpi_invoice', 'side', 'high' ); |
||
| 78 | } |
||
| 79 | } |
||
| 80 | |||
| 81 | // For payment forms. |
||
| 82 | if ( $post_type == 'wpi_payment_form' ) { |
||
| 83 | |||
| 84 | // Design payment form. |
||
| 85 | add_meta_box( 'wpinv-payment-form-design', __( 'Payment Form', 'invoicing' ), 'GetPaid_Meta_Box_Payment_Form::output', 'wpi_payment_form', 'normal' ); |
||
| 86 | |||
| 87 | // Payment form information. |
||
| 88 | add_meta_box( 'wpinv-payment-form-info', __( 'Details', 'invoicing' ), 'GetPaid_Meta_Box_Payment_Form_Info::output', 'wpi_payment_form', 'side' ); |
||
| 89 | |||
| 90 | } |
||
| 91 | |||
| 92 | // For invoice items. |
||
| 93 | if ( $post_type == 'wpi_item' ) { |
||
| 94 | |||
| 95 | // Item details. |
||
| 96 | add_meta_box( 'wpinv_item_details', __( 'Item Details', 'invoicing' ), 'GetPaid_Meta_Box_Item_Details::output', 'wpi_item', 'normal', 'high' ); |
||
| 97 | |||
| 98 | // If taxes are enabled, register the tax metabox. |
||
| 99 | if ( $wpinv_euvat->allow_vat_rules() || $wpinv_euvat->allow_vat_classes() ) { |
||
| 100 | add_meta_box( 'wpinv_item_vat', __( 'VAT / Tax', 'invoicing' ), 'GetPaid_Meta_Box_Item_VAT::output', 'wpi_item', 'normal', 'high' ); |
||
| 101 | } |
||
| 102 | |||
| 103 | // Item info. |
||
| 104 | add_meta_box( 'wpinv_field_item_info', __( 'Item info', 'invoicing' ), 'GetPaid_Meta_Box_Item_Info::output', 'wpi_item', 'side', 'core' ); |
||
| 105 | |||
| 106 | } |
||
| 107 | |||
| 108 | // For invoice discounts. |
||
| 109 | if ( $post_type == 'wpi_discount' ) { |
||
| 110 | add_meta_box( 'wpinv_discount_details', __( 'Discount Details', 'invoicing' ), 'GetPaid_Meta_Box_Discount_Details::output', 'wpi_discount', 'normal', 'high' ); |
||
| 111 | } |
||
| 193 |