| Conditions | 3 |
| Paths | 2 |
| Total Lines | 74 |
| Code Lines | 65 |
| 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 |
||
| 24 | public static function output( $post ) { |
||
| 25 | |||
| 26 | // Prepare the invoice. |
||
| 27 | $invoice = new WPInv_Invoice( $post ); |
||
| 28 | |||
| 29 | ?> |
||
| 30 | |||
| 31 | <style> |
||
| 32 | #poststuff .input-group-text, |
||
| 33 | #poststuff .form-control { |
||
| 34 | border-color: #7e8993; |
||
| 35 | } |
||
| 36 | |||
| 37 | #wpinv-details label { |
||
| 38 | margin-bottom: 3px; |
||
| 39 | font-weight: 600; |
||
| 40 | } |
||
| 41 | </style> |
||
| 42 | |||
| 43 | <div class="bsui" style="margin-top: 1.5rem"> |
||
| 44 | |||
| 45 | <?php if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) : ?> |
||
| 46 | <?php do_action( 'wpinv_meta_box_before_invoice_template_row', $invoice->get_id() ); ?> |
||
| 47 | |||
| 48 | <div class="row"> |
||
| 49 | <div class="col-12 col-sm-6"> |
||
| 50 | <?php |
||
| 51 | echo aui()->select( |
||
| 52 | array( |
||
| 53 | 'id' => 'wpinv_template', |
||
| 54 | 'name' => 'wpinv_template', |
||
| 55 | 'label' => __( 'Template', 'invoicing' ), |
||
| 56 | 'label_type' => 'vertical', |
||
| 57 | 'placeholder' => __( 'Choose a template', 'invoicing' ), |
||
| 58 | 'class' => 'form-control-sm', |
||
| 59 | 'value' => $invoice->get_template( 'edit' ), |
||
| 60 | 'options' => array( |
||
| 61 | 'quantity' => __( 'Quantity', 'invoicing' ), |
||
| 62 | 'hours' => __( 'Hours', 'invoicing' ), |
||
| 63 | 'amount' => __( 'Amount Only', 'invoicing' ), |
||
| 64 | ), |
||
| 65 | 'data-allow-clear' => 'false', |
||
| 66 | 'select2' => true, |
||
| 67 | ) |
||
| 68 | ); |
||
| 69 | ?> |
||
| 70 | </div> |
||
| 71 | <div class="col-12 col-sm-6"> |
||
| 72 | <?php |
||
| 73 | |||
| 74 | // Set currency. |
||
| 75 | echo aui()->select( |
||
| 76 | array( |
||
| 77 | 'id' => 'wpinv_currency', |
||
| 78 | 'name' => 'wpinv_currency', |
||
| 79 | 'label' => __( 'Currency', 'invoicing' ), |
||
| 80 | 'label_type' => 'vertical', |
||
| 81 | 'placeholder' => __( 'Select Invoice Currency', 'invoicing' ), |
||
| 82 | 'class' => 'form-control-sm', |
||
| 83 | 'value' => $invoice->get_currency( 'edit' ), |
||
| 84 | 'required' => false, |
||
| 85 | 'data-allow-clear' => 'false', |
||
| 86 | 'select2' => true, |
||
| 87 | 'options' => wpinv_get_currencies(), |
||
| 88 | ) |
||
| 89 | ); |
||
| 90 | |||
| 91 | ?> |
||
| 92 | </div> |
||
| 93 | </div> |
||
| 94 | |||
| 95 | <?php do_action( 'wpinv_meta_box_invoice_template_row', $invoice->get_id() ); ?> |
||
| 96 | <?php endif; ?> |
||
| 97 | |||
| 98 | </div> |
||
| 103 |