| Conditions | 5 |
| Paths | 4 |
| Total Lines | 271 |
| Code Lines | 236 |
| 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 | wp_nonce_field( 'getpaid_meta_nonce', 'getpaid_meta_nonce' ); |
||
| 30 | |||
| 31 | ?> |
||
| 32 | |||
| 33 | <style> |
||
| 34 | #gdmbx2-metabox-wpinv_address label { |
||
| 35 | margin-bottom: 3px; |
||
| 36 | font-weight: 600; |
||
| 37 | } |
||
| 38 | </style> |
||
| 39 | <div class="bsui" style="margin-top: 1.5rem; max-width: 820px;"> |
||
| 40 | <div id="gdmbx2-metabox-wpinv_address"> |
||
| 41 | <div class="row"> |
||
| 42 | <div class="col-12 col-sm-6"> |
||
| 43 | <div id="getpaid-invoice-user-id-wrapper" class="form-group"> |
||
| 44 | <div> |
||
| 45 | <label for="post_author_override"><?php _e( 'Customer', 'invoicing' );?></label> |
||
| 46 | </div> |
||
| 47 | <?php |
||
| 48 | wpinv_dropdown_users( |
||
| 49 | array( |
||
| 50 | 'name' => 'post_author_override', |
||
| 51 | 'selected' => $invoice->get_id() ? $invoice->get_user_id( 'edit' ) : get_current_user_id(), |
||
| 52 | 'include_selected' => true, |
||
| 53 | 'show' => 'display_name_with_email', |
||
| 54 | 'orderby' => 'user_email', |
||
| 55 | 'class' => 'wpi_select2 form-control' |
||
| 56 | ) |
||
| 57 | ); |
||
| 58 | ?> |
||
| 59 | </div> |
||
| 60 | |||
| 61 | <div id="getpaid-invoice-email-wrapper" class="d-none"> |
||
| 62 | <input type="hidden" id="getpaid-invoice-create-new-user" name="wpinv_new_user" value="" /> |
||
| 63 | <?php |
||
| 64 | echo aui()->input( |
||
| 65 | array( |
||
| 66 | 'type' => 'text', |
||
| 67 | 'id' => 'getpaid-invoice-new-user-email', |
||
| 68 | 'name' => 'wpinv_email', |
||
| 69 | 'label' => __( 'Email', 'invoicing' ) . '<span class="required">*</span>', |
||
| 70 | 'label_type' => 'vertical', |
||
| 71 | 'placeholder' => '[email protected]', |
||
| 72 | 'class' => 'form-control-sm', |
||
| 73 | ) |
||
| 74 | ); |
||
| 75 | ?> |
||
| 76 | </div> |
||
| 77 | </div> |
||
| 78 | <div class="col-12 col-sm-6 form-group mt-sm-4"> |
||
| 79 | <?php if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) : ?> |
||
| 80 | <a id="getpaid-invoice-fill-user-details" class="button button-small button-secondary" href="javascript:void(0)"> |
||
| 81 | <i aria-hidden="true" class="fa fa-refresh"></i> |
||
| 82 | <?php _e( 'Fill User Details', 'invoicing' );?> |
||
| 83 | </a> |
||
| 84 | <a id="getpaid-invoice-create-new-user-button" class="button button-small button-secondary" href="javascript:void(0)"> |
||
| 85 | <i aria-hidden="true" class="fa fa-plus"></i> |
||
| 86 | <?php _e( 'Add New User', 'invoicing' );?> |
||
| 87 | </a> |
||
| 88 | <a id="getpaid-invoice-cancel-create-new-user" class="button button-small button-secondary d-none" href="javascript:void(0)"> |
||
| 89 | <i aria-hidden="true" class="fa fa-close"></i> |
||
| 90 | <?php _e( 'Cancel', 'invoicing' );?> |
||
| 91 | </a> |
||
| 92 | <?php endif; ?> |
||
| 93 | </div> |
||
| 94 | </div> |
||
| 95 | <div class="row"> |
||
| 96 | <div class="col-12 col-sm-6"> |
||
| 97 | <?php |
||
| 98 | echo aui()->input( |
||
| 99 | array( |
||
| 100 | 'type' => 'text', |
||
| 101 | 'id' => 'wpinv_first_name', |
||
| 102 | 'name' => 'wpinv_first_name', |
||
| 103 | 'label' => __( 'First Name', 'invoicing' ), |
||
| 104 | 'label_type' => 'vertical', |
||
| 105 | 'placeholder' => 'Jane', |
||
| 106 | 'class' => 'form-control-sm', |
||
| 107 | 'value' => $invoice->get_first_name( 'edit' ), |
||
| 108 | ) |
||
| 109 | ); |
||
| 110 | ?> |
||
| 111 | </div> |
||
| 112 | <div class="col-12 col-sm-6"> |
||
| 113 | <?php |
||
| 114 | echo aui()->input( |
||
| 115 | array( |
||
| 116 | 'type' => 'text', |
||
| 117 | 'id' => 'wpinv_last_name', |
||
| 118 | 'name' => 'wpinv_last_name', |
||
| 119 | 'label' => __( 'Last Name', 'invoicing' ), |
||
| 120 | 'label_type' => 'vertical', |
||
| 121 | 'placeholder' => 'Doe', |
||
| 122 | 'class' => 'form-control-sm', |
||
| 123 | 'value' => $invoice->get_last_name( 'edit' ), |
||
| 124 | ) |
||
| 125 | ); |
||
| 126 | ?> |
||
| 127 | </div> |
||
| 128 | </div> |
||
| 129 | |||
| 130 | <div class="row"> |
||
| 131 | <div class="col-12 col-sm-6"> |
||
| 132 | <?php |
||
| 133 | echo aui()->input( |
||
| 134 | array( |
||
| 135 | 'type' => 'text', |
||
| 136 | 'id' => 'wpinv_company', |
||
| 137 | 'name' => 'wpinv_company', |
||
| 138 | 'label' => __( 'Company', 'invoicing' ), |
||
| 139 | 'label_type' => 'vertical', |
||
| 140 | 'placeholder' => 'Acme Corporation', |
||
| 141 | 'class' => 'form-control-sm', |
||
| 142 | 'value' => $invoice->get_company( 'edit' ), |
||
| 143 | ) |
||
| 144 | ); |
||
| 145 | ?> |
||
| 146 | </div> |
||
| 147 | <div class="col-12 col-sm-6"> |
||
| 148 | <?php |
||
| 149 | echo aui()->input( |
||
| 150 | array( |
||
| 151 | 'type' => 'text', |
||
| 152 | 'id' => 'wpinv_vat_number', |
||
| 153 | 'name' => 'wpinv_vat_number', |
||
| 154 | 'label' => __( 'Vat Number', 'invoicing' ), |
||
| 155 | 'label_type' => 'vertical', |
||
| 156 | 'placeholder' => '1234567890', |
||
| 157 | 'class' => 'form-control-sm', |
||
| 158 | 'value' => $invoice->get_vat_number( 'edit' ), |
||
| 159 | ) |
||
| 160 | ); |
||
| 161 | ?> |
||
| 162 | </div> |
||
| 163 | </div> |
||
| 164 | |||
| 165 | <div class="row"> |
||
| 166 | <div class="col-12 col-sm-6"> |
||
| 167 | <?php |
||
| 168 | echo aui()->input( |
||
| 169 | array( |
||
| 170 | 'type' => 'text', |
||
| 171 | 'id' => 'wpinv_address', |
||
| 172 | 'name' => 'wpinv_address', |
||
| 173 | 'label' => __( 'Address', 'invoicing' ), |
||
| 174 | 'label_type' => 'vertical', |
||
| 175 | 'placeholder' => 'Blekersdijk 295', |
||
| 176 | 'class' => 'form-control-sm', |
||
| 177 | 'value' => $invoice->get_address( 'edit' ), |
||
| 178 | ) |
||
| 179 | ); |
||
| 180 | ?> |
||
| 181 | </div> |
||
| 182 | <div class="col-12 col-sm-6"> |
||
| 183 | <?php |
||
| 184 | echo aui()->input( |
||
| 185 | array( |
||
| 186 | 'type' => 'text', |
||
| 187 | 'id' => 'wpinv_city', |
||
| 188 | 'name' => 'wpinv_city', |
||
| 189 | 'label' => __( 'City', 'invoicing' ), |
||
| 190 | 'label_type' => 'vertical', |
||
| 191 | 'placeholder' => 'Dolembreux', |
||
| 192 | 'class' => 'form-control-sm', |
||
| 193 | 'value' => $invoice->get_vat_number( 'edit' ), |
||
| 194 | ) |
||
| 195 | ); |
||
| 196 | ?> |
||
| 197 | </div> |
||
| 198 | </div> |
||
| 199 | |||
| 200 | <div class="row"> |
||
| 201 | <div class="col-12 col-sm-6"> |
||
| 202 | <?php |
||
| 203 | echo aui()->select( |
||
| 204 | array( |
||
| 205 | 'id' => 'wpinv_country', |
||
| 206 | 'name' => 'wpinv_country', |
||
| 207 | 'label' => __( 'Country', 'invoicing' ), |
||
| 208 | 'label_type' => 'vertical', |
||
| 209 | 'placeholder' => __( 'Choose a country', 'invoicing' ), |
||
| 210 | 'class' => 'form-control-sm', |
||
| 211 | 'value' => $invoice->get_country( 'edit' ), |
||
| 212 | 'options' => wpinv_get_country_list(), |
||
| 213 | 'data-allow-clear' => 'false', |
||
| 214 | 'select2' => true, |
||
| 215 | ) |
||
| 216 | ); |
||
| 217 | ?> |
||
| 218 | </div> |
||
| 219 | <div class="col-12 col-sm-6"> |
||
| 220 | <?php |
||
| 221 | |||
| 222 | $states = wpinv_get_country_states( $invoice->get_country( 'edit' ) ); |
||
| 223 | |||
| 224 | if ( empty( $states ) ) { |
||
| 225 | |||
| 226 | echo aui()->input( |
||
| 227 | array( |
||
| 228 | 'type' => 'text', |
||
| 229 | 'id' => 'wpinv_state', |
||
| 230 | 'name' => 'wpinv_state', |
||
| 231 | 'label' => __( 'State', 'invoicing' ), |
||
| 232 | 'label_type' => 'vertical', |
||
| 233 | 'placeholder' => 'Liège', |
||
| 234 | 'class' => 'form-control-sm', |
||
| 235 | 'value' => $invoice->get_state( 'edit' ), |
||
| 236 | ) |
||
| 237 | ); |
||
| 238 | |||
| 239 | } else { |
||
| 240 | |||
| 241 | echo aui()->select( |
||
| 242 | array( |
||
| 243 | 'id' => 'wpinv_state', |
||
| 244 | 'name' => 'wpinv_state', |
||
| 245 | 'label' => __( 'State', 'invoicing' ), |
||
| 246 | 'label_type' => 'vertical', |
||
| 247 | 'placeholder' => __( 'Select a state', 'invoicing' ), |
||
| 248 | 'class' => 'form-control-sm', |
||
| 249 | 'value' => $invoice->get_state( 'edit' ), |
||
| 250 | 'options' => $states, |
||
| 251 | 'data-allow-clear' => 'false', |
||
| 252 | 'select2' => true, |
||
| 253 | ) |
||
| 254 | ); |
||
| 255 | |||
| 256 | } |
||
| 257 | |||
| 258 | ?> |
||
| 259 | </div> |
||
| 260 | </div> |
||
| 261 | |||
| 262 | <div class="row"> |
||
| 263 | <div class="col-12 col-sm-6"> |
||
| 264 | <?php |
||
| 265 | echo aui()->input( |
||
| 266 | array( |
||
| 267 | 'type' => 'text', |
||
| 268 | 'id' => 'wpinv_zip', |
||
| 269 | 'name' => 'wpinv_zip', |
||
| 270 | 'label' => __( 'Zip / Postal Code', 'invoicing' ), |
||
| 271 | 'label_type' => 'vertical', |
||
| 272 | 'placeholder' => '4140', |
||
| 273 | 'class' => 'form-control-sm', |
||
| 274 | 'value' => $invoice->get_zip( 'edit' ), |
||
| 275 | ) |
||
| 276 | ); |
||
| 277 | ?> |
||
| 278 | </div> |
||
| 279 | <div class="col-12 col-sm-6"> |
||
| 280 | <?php |
||
| 281 | echo aui()->input( |
||
| 282 | array( |
||
| 283 | 'type' => 'text', |
||
| 284 | 'id' => 'wpinv_phone', |
||
| 285 | 'name' => 'wpinv_phone', |
||
| 286 | 'label' => __( 'Phone', 'invoicing' ), |
||
| 287 | 'label_type' => 'vertical', |
||
| 288 | 'placeholder' => '0493 18 45822', |
||
| 289 | 'class' => 'form-control-sm', |
||
| 290 | 'value' => $invoice->get_phone( 'edit' ), |
||
| 291 | ) |
||
| 292 | ); |
||
| 293 | ?> |
||
| 294 | </div> |
||
| 295 | </div> |
||
| 368 |