From e8f264c3460a71ca9fd0450c893fb8578c038f79 Mon Sep 17 00:00:00 2001 From: Peter Fabian Date: Fri, 18 Jan 2019 14:08:34 +0100 Subject: [PATCH] Moved common code to parent class. --- ...-admin-reports-orders-stats-segmenting.php | 26 ------------------- ...dmin-reports-products-stats-segmenting.php | 26 ------------------- .../class-wc-admin-reports-segmenting.php | 26 +++++++++++++++++++ 3 files changed, 26 insertions(+), 52 deletions(-) diff --git a/plugins/woocommerce-admin/includes/class-wc-admin-reports-orders-stats-segmenting.php b/plugins/woocommerce-admin/includes/class-wc-admin-reports-orders-stats-segmenting.php index 26ad9a3400f..8d244feea52 100644 --- a/plugins/woocommerce-admin/includes/class-wc-admin-reports-orders-stats-segmenting.php +++ b/plugins/woocommerce-admin/includes/class-wc-admin-reports-orders-stats-segmenting.php @@ -413,30 +413,4 @@ class WC_Admin_Reports_Orders_Stats_Segmenting extends WC_Admin_Reports_Segmenti return $segments; } - - /** - * Returns an array of segments for totals part of REST response. - * - * @param array $query_params Totals SQL query parameters. - * @param string $table_name Name of the SQL table that is the main order stats table. - * - * @return array - */ - public function get_totals_segments( $query_params, $table_name ) { - $segments = $this->get_segments( 'totals', $query_params, $table_name ); - return $this->fill_in_missing_segments( $segments ); - } - - /** - * Adds an array of segments to data->intervals object. - * - * @param stdClass $data Data object representing the REST response. - * @param array $intervals_query Intervals SQL query parameters. - * @param string $table_name Name of the SQL table that is the main order stats table. - */ - public function add_intervals_segments( &$data, $intervals_query, $table_name ) { - $intervals_segments = $this->get_segments( 'intervals', $intervals_query, $table_name ); - $this->assign_segments_to_intervals( $data->intervals, $intervals_segments ); - $this->fill_in_missing_interval_segments( $data ); - } } diff --git a/plugins/woocommerce-admin/includes/class-wc-admin-reports-products-stats-segmenting.php b/plugins/woocommerce-admin/includes/class-wc-admin-reports-products-stats-segmenting.php index 72803b06572..f96b92b1adb 100644 --- a/plugins/woocommerce-admin/includes/class-wc-admin-reports-products-stats-segmenting.php +++ b/plugins/woocommerce-admin/includes/class-wc-admin-reports-products-stats-segmenting.php @@ -186,30 +186,4 @@ class WC_Admin_Reports_Products_Stats_Segmenting extends WC_Admin_Reports_Segmen return $segments; } - - /** - * Returns an array of segments for totals part of REST response. - * - * @param array $query_params Totals SQL query parameters. - * @param string $table_name Name of the SQL table that is the main order stats table. - * - * @return array - */ - public function get_totals_segments( $query_params, $table_name ) { - $segments = $this->get_segments( 'totals', $query_params, $table_name ); - return $this->fill_in_missing_segments( $segments ); - } - - /** - * Adds an array of segments to data->intervals object. - * - * @param stdClass $data Data object representing the REST response. - * @param array $intervals_query Intervals SQL query parameters. - * @param string $table_name Name of the SQL table that is the main order stats table. - */ - public function add_intervals_segments( &$data, $intervals_query, $table_name ) { - $intervals_segments = $this->get_segments( 'intervals', $intervals_query, $table_name ); - $this->assign_segments_to_intervals( $data->intervals, $intervals_segments ); - $this->fill_in_missing_interval_segments( $data ); - } } diff --git a/plugins/woocommerce-admin/includes/class-wc-admin-reports-segmenting.php b/plugins/woocommerce-admin/includes/class-wc-admin-reports-segmenting.php index 96424eeb16e..e98132bb048 100644 --- a/plugins/woocommerce-admin/includes/class-wc-admin-reports-segmenting.php +++ b/plugins/woocommerce-admin/includes/class-wc-admin-reports-segmenting.php @@ -478,4 +478,30 @@ class WC_Admin_Reports_Segmenting { // To remove time interval keys (so that REST response is formatted correctly). $intervals = array_values( $intervals ); } + + /** + * Returns an array of segments for totals part of REST response. + * + * @param array $query_params Totals SQL query parameters. + * @param string $table_name Name of the SQL table that is the main order stats table. + * + * @return array + */ + public function get_totals_segments( $query_params, $table_name ) { + $segments = $this->get_segments( 'totals', $query_params, $table_name ); + return $this->fill_in_missing_segments( $segments ); + } + + /** + * Adds an array of segments to data->intervals object. + * + * @param stdClass $data Data object representing the REST response. + * @param array $intervals_query Intervals SQL query parameters. + * @param string $table_name Name of the SQL table that is the main order stats table. + */ + public function add_intervals_segments( &$data, $intervals_query, $table_name ) { + $intervals_segments = $this->get_segments( 'intervals', $intervals_query, $table_name ); + $this->assign_segments_to_intervals( $data->intervals, $intervals_segments ); + $this->fill_in_missing_interval_segments( $data ); + } }