Code Duplication    Length = 37-41 lines in 2 locations

includes/class-wpinv-invoice.php 2 locations

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