Code Duplication    Length = 37-41 lines in 2 locations

includes/class-wpinv-invoice.php 2 locations

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