Code Duplication    Length = 15-15 lines in 4 locations

includes/wpinv-payment-functions.php 4 locations

@@ 77-91 (lines=15) @@
74
    $description = '';
75
    switch ( $period ) {
76
        case 'D' :
77
        case 'day' :            
78
            if ( (int)$bill_times > 0 ) {
79
                if ( $interval > 1 ) {
80
                    if ( $bill_times > 1 ) {
81
                        $description = wp_sprintf( __( '%s for each %d days, for %d installments.', 'invoicing' ), $amount, $interval, $bill_times );
82
                    } else {
83
                        $description = wp_sprintf( __( '%s for %d days.', 'invoicing' ), $amount, $interval );
84
                    }
85
                } else {
86
                    $description = wp_sprintf( _n( '%s for one day.', '%s for each day, for %d installments.', $bill_times, 'invoicing' ), $amount, $bill_times );
87
                }
88
            } else {
89
                $description = wp_sprintf( _n( '%s for each day.', '%s for each %d days.', $interval, 'invoicing'), $amount, $interval );
90
            }
91
            break;
92
        case 'W' :
93
        case 'week' :            
94
            if ( (int)$bill_times > 0 ) {
@@ 93-107 (lines=15) @@
90
            }
91
            break;
92
        case 'W' :
93
        case 'week' :            
94
            if ( (int)$bill_times > 0 ) {
95
                if ( $interval > 1 ) {
96
                    if ( $bill_times > 1 ) {
97
                        $description = wp_sprintf( __( '%s for each %d weeks, for %d installments.', 'invoicing' ), $amount, $interval, $bill_times );
98
                    } else {
99
                        $description = wp_sprintf( __( '%s for %d weeks.', 'invoicing' ), $amount, $interval );
100
                    }
101
                } else {
102
                    $description = wp_sprintf( _n( '%s for one week.', '%s for each week, for %d installments.', $bill_times, 'invoicing' ), $amount, $bill_times );
103
                }
104
            } else {
105
                $description = wp_sprintf( _n( '%s for each week.', '%s for each %d weeks.', $interval, 'invoicing' ), $amount, $interval );
106
            }
107
            break;
108
        case 'M' :
109
        case 'month' :            
110
            if ( (int)$bill_times > 0 ) {
@@ 109-123 (lines=15) @@
106
            }
107
            break;
108
        case 'M' :
109
        case 'month' :            
110
            if ( (int)$bill_times > 0 ) {
111
                if ( $interval > 1 ) {
112
                    if ( $bill_times > 1 ) {
113
                        $description = wp_sprintf( __( '%s for each %d months, for %d installments.', 'invoicing' ), $amount, $interval, $bill_times );
114
                    } else {
115
                        $description = wp_sprintf( __( '%s for %d months.', 'invoicing' ), $amount, $interval );
116
                    }
117
                } else {
118
                    $description = wp_sprintf( _n( '%s for one month.', '%s for each month, for %d installments.', $bill_times, 'invoicing' ), $amount, $bill_times );
119
                }
120
            } else {
121
                $description = wp_sprintf( _n( '%s for each month.', '%s for each %d months.', $interval, 'invoicing' ), $amount, $interval );
122
            }
123
            break;
124
        case 'Y' :
125
        case 'year' :            
126
            if ( (int)$bill_times > 0 ) {
@@ 125-139 (lines=15) @@
122
            }
123
            break;
124
        case 'Y' :
125
        case 'year' :            
126
            if ( (int)$bill_times > 0 ) {
127
                if ( $interval > 1 ) {
128
                    if ( $bill_times > 1 ) {
129
                        $description = wp_sprintf( __( '%s for each %d years, for %d installments.', 'invoicing' ), $amount, $interval, $bill_times );
130
                    } else {
131
                        $description = wp_sprintf( __( '%s for %d years.', 'invoicing'), $amount, $interval );
132
                    }
133
                } else {
134
                    $description = wp_sprintf( _n( '%s for one year.', '%s for each year, for %d installments.', $bill_times, 'invoicing' ), $amount, $bill_times );
135
                }
136
            } else {
137
                $description = wp_sprintf( _n( '%s for each year.', '%s for each %d years.', $interval, 'invoicing' ), $amount, $interval );
138
            }
139
            break;
140
    }
141
142
    return apply_filters( 'wpinv_subscription_recurring_payment_desc', $description, $amount, $period, $interval, $bill_times, $trial_period, $trial_interval );