Code Duplication    Length = 30-30 lines in 4 locations

includes/class-wpinv-subscriptions-db.php 4 locations

@@ 197-226 (lines=30) @@
194
        }
195
196
        // Subscriptions created for a specific date or in a date range
197
        if( ! empty( $args['date'] ) ) {
198
199
            if( is_array( $args['date'] ) ) {
200
201
                if( ! empty( $args['date']['start'] ) ) {
202
203
                    $start = date( 'Y-m-d H:i:s', strtotime( $args['date']['start'] ) );
204
205
                    $where .= " AND `created` >= '{$start}'";
206
207
                }
208
209
                if( ! empty( $args['date']['end'] ) ) {
210
211
                    $end = date( 'Y-m-d H:i:s', strtotime( $args['date']['end'] ) );
212
213
                    $where .= " AND `created` <= '{$end}'";
214
215
                }
216
217
            } else {
218
219
                $year  = date( 'Y', strtotime( $args['date'] ) );
220
                $month = date( 'm', strtotime( $args['date'] ) );
221
                $day   = date( 'd', strtotime( $args['date'] ) );
222
223
                $where .= " AND $year = YEAR ( created ) AND $month = MONTH ( created ) AND $day = DAY ( created )";
224
            }
225
226
        }
227
228
        // Subscriptions with a specific expiration date or in an expiration date range
229
        if( ! empty( $args['expiration'] ) ) {
@@ 229-258 (lines=30) @@
226
        }
227
228
        // Subscriptions with a specific expiration date or in an expiration date range
229
        if( ! empty( $args['expiration'] ) ) {
230
231
            if( is_array( $args['expiration'] ) ) {
232
233
                if( ! empty( $args['expiration']['start'] ) ) {
234
235
                    $start = date( 'Y-m-d H:i:s', strtotime( $args['expiration']['start'] ) );
236
237
                    $where .= " AND `expiration` >= '{$start}'";
238
239
                }
240
241
                if( ! empty( $args['expiration']['end'] ) ) {
242
243
                    $end = date( 'Y-m-d H:i:s', strtotime( $args['expiration']['end'] ) );
244
245
                    $where .= " AND `expiration` <= '{$end}'";
246
247
                }
248
249
            } else {
250
251
                $year  = date( 'Y', strtotime( $args['expiration'] ) );
252
                $month = date( 'm', strtotime( $args['expiration'] ) );
253
                $day   = date( 'd', strtotime( $args['expiration'] ) );
254
255
                $where .= " AND $year = YEAR ( expiration ) AND $month = MONTH ( expiration ) AND $day = DAY ( expiration )";
256
            }
257
258
        }
259
260
        if ( ! empty( $args['search'] ) ) {
261
@@ 432-461 (lines=30) @@
429
        }
430
431
        // Subscriptions created for a specific date or in a date range
432
        if( ! empty( $args['date'] ) ) {
433
434
            if( is_array( $args['date'] ) ) {
435
436
                if( ! empty( $args['date']['start'] ) ) {
437
438
                    $start = date( 'Y-m-d H:i:s', strtotime( $args['date']['start'] ) );
439
440
                    $where .= " AND `created` >= '{$start}'";
441
442
                }
443
444
                if( ! empty( $args['date']['end'] ) ) {
445
446
                    $end = date( 'Y-m-d H:i:s', strtotime( $args['date']['end'] ) );
447
448
                    $where .= " AND `created` <= '{$end}'";
449
450
                }
451
452
            } else {
453
454
                $year  = date( 'Y', strtotime( $args['date'] ) );
455
                $month = date( 'm', strtotime( $args['date'] ) );
456
                $day   = date( 'd', strtotime( $args['date'] ) );
457
458
                $where .= " AND $year = YEAR ( created ) AND $month = MONTH ( created ) AND $day = DAY ( created )";
459
            }
460
461
        }
462
463
        // Subscriptions with a specific expiration date or in an expiration date range
464
        if( ! empty( $args['expiration'] ) ) {
@@ 464-493 (lines=30) @@
461
        }
462
463
        // Subscriptions with a specific expiration date or in an expiration date range
464
        if( ! empty( $args['expiration'] ) ) {
465
466
            if( is_array( $args['expiration'] ) ) {
467
468
                if( ! empty( $args['expiration']['start'] ) ) {
469
470
                    $start = date( 'Y-m-d H:i:s', strtotime( $args['expiration']['start'] ) );
471
472
                    $where .= " AND `expiration` >= '{$start}'";
473
474
                }
475
476
                if( ! empty( $args['expiration']['end'] ) ) {
477
478
                    $end = date( 'Y-m-d H:i:s', strtotime( $args['expiration']['end'] ) );
479
480
                    $where .= " AND `expiration` <= '{$end}'";
481
482
                }
483
484
            } else {
485
486
                $year  = date( 'Y', strtotime( $args['expiration'] ) );
487
                $month = date( 'm', strtotime( $args['expiration'] ) );
488
                $day   = date( 'd', strtotime( $args['expiration'] ) );
489
490
                $where .= " AND $year = YEAR ( expiration ) AND $month = MONTH ( expiration ) AND $day = DAY ( expiration )";
491
            }
492
493
        }
494
495
        if ( ! empty( $args['search'] ) ) {
496