Code Duplication    Length = 37-41 lines in 2 locations

includes/class-wpinv-invoice.php 2 locations

@@ 2314-2350 (lines=37) @@
2311
        return $status_label;
2312
    }
2313
    
2314
    public function get_subscription_period( $full = false ) {
2315
        $period = $this->get_meta( '_wpinv_subscr_period', true );
2316
        
2317
        // Fix period for old invoices
2318
        if ( $period == 'day' ) {
2319
            $period = 'D';
2320
        } else if ( $period == 'week' ) {
2321
            $period = 'W';
2322
        } else if ( $period == 'month' ) {
2323
            $period = 'M';
2324
        } else if ( $period == 'year' ) {
2325
            $period = 'Y';
2326
        }
2327
        
2328
        if ( !in_array( $period, array( 'D', 'W', 'M', 'Y' ) ) ) {
2329
            $period = 'D';
2330
        }
2331
        
2332
        if ( $full ) {
2333
            switch( $period ) {
2334
                case 'D':
2335
                    $period = 'day';
2336
                break;
2337
                case 'W':
2338
                    $period = 'week';
2339
                break;
2340
                case 'M':
2341
                    $period = 'month';
2342
                break;
2343
                case 'Y':
2344
                    $period = 'year';
2345
                break;
2346
            }
2347
        }
2348
        
2349
        return $period;
2350
    }
2351
    
2352
    public function get_subscription_interval() {
2353
        $interval = (int)$this->get_meta( '_wpinv_subscr_interval', true );
@@ 2362-2402 (lines=41) @@
2359
        return $interval;
2360
    }
2361
    
2362
    public function get_subscription_trial_period( $full = false ) {
2363
        if ( !$this->is_free_trial() ) {
2364
            return '';
2365
        }
2366
        
2367
        $period = $this->get_meta( '_wpinv_subscr_trial_period', true );
2368
        
2369
        // Fix period for old invoices
2370
        if ( $period == 'day' ) {
2371
            $period = 'D';
2372
        } else if ( $period == 'week' ) {
2373
            $period = 'W';
2374
        } else if ( $period == 'month' ) {
2375
            $period = 'M';
2376
        } else if ( $period == 'year' ) {
2377
            $period = 'Y';
2378
        }
2379
        
2380
        if ( !in_array( $period, array( 'D', 'W', 'M', 'Y' ) ) ) {
2381
            $period = 'D';
2382
        }
2383
        
2384
        if ( $full ) {
2385
            switch( $period ) {
2386
                case 'D':
2387
                    $period = 'day';
2388
                break;
2389
                case 'W':
2390
                    $period = 'week';
2391
                break;
2392
                case 'M':
2393
                    $period = 'month';
2394
                break;
2395
                case 'Y':
2396
                    $period = 'year';
2397
                break;
2398
            }
2399
        }
2400
        
2401
        return $period;
2402
    }
2403
    
2404
    public function get_subscription_trial_interval() {
2405
        if ( !$this->is_free_trial() ) {