Code Duplication    Length = 37-41 lines in 2 locations

includes/class-wpinv-invoice.php 2 locations

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