Code Duplication    Length = 37-41 lines in 2 locations

includes/class-wpinv-invoice.php 2 locations

@@ 2330-2366 (lines=37) @@
2327
        return $status_label;
2328
    }
2329
    
2330
    public function get_subscription_period( $full = false ) {
2331
        $period = $this->get_meta( '_wpinv_subscr_period', true );
2332
        
2333
        // Fix period for old invoices
2334
        if ( $period == 'day' ) {
2335
            $period = 'D';
2336
        } else if ( $period == 'week' ) {
2337
            $period = 'W';
2338
        } else if ( $period == 'month' ) {
2339
            $period = 'M';
2340
        } else if ( $period == 'year' ) {
2341
            $period = 'Y';
2342
        }
2343
        
2344
        if ( !in_array( $period, array( 'D', 'W', 'M', 'Y' ) ) ) {
2345
            $period = 'D';
2346
        }
2347
        
2348
        if ( $full ) {
2349
            switch( $period ) {
2350
                case 'D':
2351
                    $period = 'day';
2352
                break;
2353
                case 'W':
2354
                    $period = 'week';
2355
                break;
2356
                case 'M':
2357
                    $period = 'month';
2358
                break;
2359
                case 'Y':
2360
                    $period = 'year';
2361
                break;
2362
            }
2363
        }
2364
        
2365
        return $period;
2366
    }
2367
    
2368
    public function get_subscription_interval() {
2369
        $interval = (int)$this->get_meta( '_wpinv_subscr_interval', true );
@@ 2378-2418 (lines=41) @@
2375
        return $interval;
2376
    }
2377
    
2378
    public function get_subscription_trial_period( $full = false ) {
2379
        if ( !$this->is_free_trial() ) {
2380
            return '';
2381
        }
2382
        
2383
        $period = $this->get_meta( '_wpinv_subscr_trial_period', true );
2384
        
2385
        // Fix period for old invoices
2386
        if ( $period == 'day' ) {
2387
            $period = 'D';
2388
        } else if ( $period == 'week' ) {
2389
            $period = 'W';
2390
        } else if ( $period == 'month' ) {
2391
            $period = 'M';
2392
        } else if ( $period == 'year' ) {
2393
            $period = 'Y';
2394
        }
2395
        
2396
        if ( !in_array( $period, array( 'D', 'W', 'M', 'Y' ) ) ) {
2397
            $period = 'D';
2398
        }
2399
        
2400
        if ( $full ) {
2401
            switch( $period ) {
2402
                case 'D':
2403
                    $period = 'day';
2404
                break;
2405
                case 'W':
2406
                    $period = 'week';
2407
                break;
2408
                case 'M':
2409
                    $period = 'month';
2410
                break;
2411
                case 'Y':
2412
                    $period = 'year';
2413
                break;
2414
            }
2415
        }
2416
        
2417
        return $period;
2418
    }
2419
    
2420
    public function get_subscription_trial_interval() {
2421
        if ( !$this->is_free_trial() ) {