Code Duplication    Length = 3-3 lines in 4 locations

includes/wpinv-tax-functions.php 1 location

@@ 235-237 (lines=3) @@
232
        return false;
233
    }
234
235
    if ( empty( $_POST['country'] ) ) {
236
        $_POST['country'] = !empty($invoice->country) ? $invoice->country : wpinv_get_default_country();
237
    }
238
        
239
    $invoice->country = sanitize_text_field($_POST['country']);
240
    $invoice->set( 'country', sanitize_text_field( $_POST['country'] ) );

includes/class-wpinv-ajax.php 3 locations

@@ 226-228 (lines=3) @@
223
        $invoice->add_item( $item_id, $args );
224
        $invoice->save();
225
        
226
        if ( empty( $_POST['country'] ) ) {
227
            $_POST['country'] = !empty($invoice->country) ? $invoice->country : wpinv_get_default_country();
228
        }
229
        if ( empty( $_POST['state'] ) ) {
230
            $_POST['state'] = $invoice->state;
231
        }
@@ 311-313 (lines=3) @@
308
        $invoice->remove_item( $item_id, $args );
309
        $invoice->save();
310
        
311
        if ( empty( $_POST['country'] ) ) {
312
            $_POST['country'] = !empty($invoice->country) ? $invoice->country : wpinv_get_default_country();
313
        }
314
        if ( empty( $_POST['state'] ) ) {
315
            $_POST['state'] = $invoice->state;
316
        }
@@ 448-450 (lines=3) @@
445
            $wpi_userID = absint( $_POST['user_id'] ); 
446
        }
447
        
448
        if ( empty( $_POST['country'] ) ) {
449
            $_POST['country'] = !empty($invoice->country) ? $invoice->country : wpinv_get_default_country();
450
        }
451
            
452
        $invoice->country = sanitize_text_field( $_POST['country'] );
453
        $invoice->set( 'country', sanitize_text_field( $_POST['country'] ) );