Code Duplication    Length = 11-11 lines in 2 locations

includes/api/class-wc-rest-report-sales-controller.php 1 location

@@ 256-266 (lines=11) @@
253
			// Custom date range.
254
			$filter['period'] = 'custom';
255
256
			if ( ! empty( $filter['date_min'] ) || ! empty( $filter['date_max'] ) ) {
257
258
				// Overwrite _GET to make use of WC_Admin_Report::calculate_current_range() for custom date ranges.
259
				$_GET['start_date'] = $filter['date_min'];
260
				$_GET['end_date'] = isset( $filter['date_max'] ) ? $filter['date_max'] : null;
261
262
			} else {
263
264
				// Default custom range to today.
265
				$_GET['start_date'] = $_GET['end_date'] = date( 'Y-m-d', current_time( 'timestamp' ) );
266
			}
267
268
		} else {
269

includes/cli/class-wc-cli-report.php 1 location

@@ 332-342 (lines=11) @@
329
			// custom date range
330
			$assoc_args['period'] = 'custom';
331
332
			if ( ! empty( $assoc_args['date_min'] ) || ! empty( $assoc_args['date_max'] ) ) {
333
334
				// overwrite _GET to make use of WC_Admin_Report::calculate_current_range() for custom date ranges
335
				$_GET['start_date'] = $this->parse_datetime( $assoc_args['date_min'] );
336
				$_GET['end_date'] = isset( $assoc_args['date_max'] ) ? $this->parse_datetime( $assoc_args['date_max'] ) : null;
337
338
			} else {
339
340
				// default custom range to today
341
				$_GET['start_date'] = $_GET['end_date'] = date( 'Y-m-d', current_time( 'timestamp' ) );
342
			}
343
344
		} else {
345