Code Duplication    Length = 37-41 lines in 2 locations

includes/class-wpinv-invoice.php 2 locations

@@ 2343-2379 (lines=37) @@
2340
        return $status_label;
2341
    }
2342
    
2343
    public function get_subscription_period( $full = false ) {
2344
        $period = $this->get_meta( '_wpinv_subscr_period', true );
2345
        
2346
        // Fix period for old invoices
2347
        if ( $period == 'day' ) {
2348
            $period = 'D';
2349
        } else if ( $period == 'week' ) {
2350
            $period = 'W';
2351
        } else if ( $period == 'month' ) {
2352
            $period = 'M';
2353
        } else if ( $period == 'year' ) {
2354
            $period = 'Y';
2355
        }
2356
        
2357
        if ( !in_array( $period, array( 'D', 'W', 'M', 'Y' ) ) ) {
2358
            $period = 'D';
2359
        }
2360
        
2361
        if ( $full ) {
2362
            switch( $period ) {
2363
                case 'D':
2364
                    $period = 'day';
2365
                break;
2366
                case 'W':
2367
                    $period = 'week';
2368
                break;
2369
                case 'M':
2370
                    $period = 'month';
2371
                break;
2372
                case 'Y':
2373
                    $period = 'year';
2374
                break;
2375
            }
2376
        }
2377
        
2378
        return $period;
2379
    }
2380
    
2381
    public function get_subscription_interval() {
2382
        $interval = (int)$this->get_meta( '_wpinv_subscr_interval', true );
@@ 2391-2431 (lines=41) @@
2388
        return $interval;
2389
    }
2390
    
2391
    public function get_subscription_trial_period( $full = false ) {
2392
        if ( !$this->is_free_trial() ) {
2393
            return '';
2394
        }
2395
        
2396
        $period = $this->get_meta( '_wpinv_subscr_trial_period', true );
2397
        
2398
        // Fix period for old invoices
2399
        if ( $period == 'day' ) {
2400
            $period = 'D';
2401
        } else if ( $period == 'week' ) {
2402
            $period = 'W';
2403
        } else if ( $period == 'month' ) {
2404
            $period = 'M';
2405
        } else if ( $period == 'year' ) {
2406
            $period = 'Y';
2407
        }
2408
        
2409
        if ( !in_array( $period, array( 'D', 'W', 'M', 'Y' ) ) ) {
2410
            $period = 'D';
2411
        }
2412
        
2413
        if ( $full ) {
2414
            switch( $period ) {
2415
                case 'D':
2416
                    $period = 'day';
2417
                break;
2418
                case 'W':
2419
                    $period = 'week';
2420
                break;
2421
                case 'M':
2422
                    $period = 'month';
2423
                break;
2424
                case 'Y':
2425
                    $period = 'year';
2426
                break;
2427
            }
2428
        }
2429
        
2430
        return $period;
2431
    }
2432
    
2433
    public function get_subscription_trial_interval() {
2434
        if ( !$this->is_free_trial() ) {