Code Duplication    Length = 15-15 lines in 4 locations

includes/wpinv-payment-functions.php 4 locations

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