| Conditions | 8 |
| Paths | 33 |
| Total Lines | 84 |
| Code Lines | 49 |
| Lines | 0 |
| Ratio | 0 % |
| 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 |
||
| 104 | protected static function add_invoice_meta_boxes( $post_type, $post ) { |
||
| 105 | |||
| 106 | // For invoices... |
||
| 107 | if ( getpaid_is_invoice_post_type( $post_type ) ) { |
||
| 108 | $invoice = new WPInv_Invoice( $post ); |
||
| 109 | |||
| 110 | // Resend invoice. |
||
| 111 | if ( ! $invoice->is_draft() && ! $invoice->is_paid() ) { |
||
| 112 | |||
| 113 | add_meta_box( |
||
| 114 | 'wpinv-mb-resend-invoice', |
||
| 115 | sprintf( |
||
| 116 | __( 'Resend %s', 'invoicing' ), |
||
| 117 | ucfirst( $invoice->get_invoice_quote_type() ) |
||
| 118 | ), |
||
| 119 | 'GetPaid_Meta_Box_Resend_Invoice::output', |
||
| 120 | $post_type, |
||
| 121 | 'side', |
||
| 122 | 'low' |
||
| 123 | ); |
||
| 124 | |||
| 125 | } |
||
| 126 | |||
| 127 | // Subscriptions. |
||
| 128 | $subscription = getpaid_get_invoice_subscription( $invoice ); |
||
| 129 | if ( ! empty( $subscription ) ) { |
||
| 130 | add_meta_box( 'wpinv-mb-subscriptions', __( 'Subscription Details', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Subscription::output', $post_type, 'advanced' ); |
||
| 131 | add_meta_box( 'wpinv-mb-subscription-invoices', __( 'Related Payments', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Subscription::output_invoices', $post_type, 'advanced' ); |
||
| 132 | } |
||
| 133 | |||
| 134 | // Invoice details. |
||
| 135 | add_meta_box( |
||
| 136 | 'wpinv-details', |
||
| 137 | sprintf( |
||
| 138 | __( '%s Details', 'invoicing' ), |
||
| 139 | ucfirst( $invoice->get_invoice_quote_type() ) |
||
| 140 | ), |
||
| 141 | 'GetPaid_Meta_Box_Invoice_Details::output', |
||
| 142 | $post_type, |
||
| 143 | 'side' |
||
| 144 | ); |
||
| 145 | |||
| 146 | // Payment details. |
||
| 147 | if ( ! $invoice->is_draft() ) { |
||
| 148 | add_meta_box( 'wpinv-payment-meta', __( 'Payment Meta', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Payment_Meta::output', $post_type, 'side', 'default' ); |
||
| 149 | } |
||
| 150 | |||
| 151 | // Billing details. |
||
| 152 | add_meta_box( 'wpinv-address', __( 'Billing Details', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Address::output', $post_type, 'normal', 'high' ); |
||
| 153 | |||
| 154 | // Invoice items. |
||
| 155 | add_meta_box( |
||
| 156 | 'wpinv-items', |
||
| 157 | sprintf( |
||
| 158 | __( '%s Items', 'invoicing' ), |
||
| 159 | ucfirst( $invoice->get_invoice_quote_type() ) |
||
| 160 | ), |
||
| 161 | 'GetPaid_Meta_Box_Invoice_Items::output', |
||
| 162 | $post_type, |
||
| 163 | 'normal', |
||
| 164 | 'high' |
||
| 165 | ); |
||
| 166 | |||
| 167 | // Invoice notes. |
||
| 168 | add_meta_box( |
||
| 169 | 'wpinv-notes', |
||
| 170 | sprintf( |
||
| 171 | __( '%s Notes', 'invoicing' ), |
||
| 172 | ucfirst( $invoice->get_invoice_quote_type() ) |
||
| 173 | ), |
||
| 174 | 'WPInv_Meta_Box_Notes::output', |
||
| 175 | $post_type, |
||
| 176 | 'side', |
||
| 177 | 'low' |
||
| 178 | ); |
||
| 179 | |||
| 180 | // Shipping Address. |
||
| 181 | if ( get_post_meta( $invoice->get_id(), 'shipping_address', true ) ) { |
||
| 182 | add_meta_box( 'wpinv-invoice-shipping-details', __( 'Shipping Address', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Shipping_Address::output', $post_type, 'side', 'high' ); |
||
| 183 | } |
||
| 184 | |||
| 185 | // Payment form information. |
||
| 186 | if ( get_post_meta( $invoice->get_id(), 'payment_form_data', true ) ) { |
||
| 187 | add_meta_box( 'wpinv-invoice-payment-form-details', __( 'Payment Form Details', 'invoicing' ), 'WPInv_Meta_Box_Payment_Form::output_details', $post_type, 'side', 'high' ); |
||
| 188 | } |
||
| 279 |
This check looks for function or method calls that always return null and whose return value is used.
The method
getObject()can return nothing but null, so it makes no sense to use the return value.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.