Completed
Branch master (99a09c)
by Mike
81:56 queued 37:04
created
src/RestApi/Version4/Controllers/Reports/Categories.php 1 patch
Spacing   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
 
10 10
 namespace WooCommerce\RestApi\Version4\Controllers\Reports;
11 11
 
12
-defined( 'ABSPATH' ) || exit;
12
+defined('ABSPATH') || exit;
13 13
 
14 14
 use \WooCommerce\RestApi\Version4\Controllers\Reports as Reports;
15 15
 
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 	 * @param array $request Request array.
32 32
 	 * @return array
33 33
 	 */
34
-	protected function prepare_reports_query( $request ) {
34
+	protected function prepare_reports_query($request) {
35 35
 		$args                  = array();
36 36
 		$args['before']        = $request['before'];
37 37
 		$args['after']         = $request['after'];
@@ -54,45 +54,45 @@  discard block
 block discarded – undo
54 54
 	 * @param \WP_REST_Request $request Request data.
55 55
 	 * @return array|\WP_Error
56 56
 	 */
57
-	public function get_items( $request ) {
58
-		$query_args       = $this->prepare_reports_query( $request );
59
-		$categories_query = new \WC_Admin_Reports_Categories_Query( $query_args );
57
+	public function get_items($request) {
58
+		$query_args       = $this->prepare_reports_query($request);
59
+		$categories_query = new \WC_Admin_Reports_Categories_Query($query_args);
60 60
 		$report_data      = $categories_query->get_data();
61 61
 
62
-		if ( is_wp_error( $report_data ) ) {
62
+		if (is_wp_error($report_data)) {
63 63
 			return $report_data;
64 64
 		}
65 65
 
66
-		if ( ! isset( $report_data->data ) || ! isset( $report_data->page_no ) || ! isset( $report_data->pages ) ) {
67
-			return new \WP_Error( 'woocommerce_rest_reports_categories_invalid_response', __( 'Invalid response from data store.', 'woocommerce' ), array( 'status' => 500 ) );
66
+		if ( ! isset($report_data->data) || ! isset($report_data->page_no) || ! isset($report_data->pages)) {
67
+			return new \WP_Error('woocommerce_rest_reports_categories_invalid_response', __('Invalid response from data store.', 'woocommerce'), array('status' => 500));
68 68
 		}
69 69
 
70 70
 		$out_data = array();
71 71
 
72
-		foreach ( $report_data->data as $datum ) {
73
-			$item       = $this->prepare_item_for_response( $datum, $request );
74
-			$out_data[] = $this->prepare_response_for_collection( $item );
72
+		foreach ($report_data->data as $datum) {
73
+			$item       = $this->prepare_item_for_response($datum, $request);
74
+			$out_data[] = $this->prepare_response_for_collection($item);
75 75
 		}
76 76
 
77
-		$response = rest_ensure_response( $out_data );
78
-		$response->header( 'X-WP-Total', (int) $report_data->total );
79
-		$response->header( 'X-WP-TotalPages', (int) $report_data->pages );
77
+		$response = rest_ensure_response($out_data);
78
+		$response->header('X-WP-Total', (int) $report_data->total);
79
+		$response->header('X-WP-TotalPages', (int) $report_data->pages);
80 80
 
81 81
 		$page      = $report_data->page_no;
82 82
 		$max_pages = $report_data->pages;
83
-		$base      = add_query_arg( $request->get_query_params(), rest_url( sprintf( '/%s/%s', $this->namespace, $this->rest_base ) ) );
84
-		if ( $page > 1 ) {
83
+		$base      = add_query_arg($request->get_query_params(), rest_url(sprintf('/%s/%s', $this->namespace, $this->rest_base)));
84
+		if ($page > 1) {
85 85
 			$prev_page = $page - 1;
86
-			if ( $prev_page > $max_pages ) {
86
+			if ($prev_page > $max_pages) {
87 87
 				$prev_page = $max_pages;
88 88
 			}
89
-			$prev_link = add_query_arg( 'page', $prev_page, $base );
90
-			$response->link_header( 'prev', $prev_link );
89
+			$prev_link = add_query_arg('page', $prev_page, $base);
90
+			$response->link_header('prev', $prev_link);
91 91
 		}
92
-		if ( $max_pages > $page ) {
92
+		if ($max_pages > $page) {
93 93
 			$next_page = $page + 1;
94
-			$next_link = add_query_arg( 'page', $next_page, $base );
95
-			$response->link_header( 'next', $next_link );
94
+			$next_link = add_query_arg('page', $next_page, $base);
95
+			$response->link_header('next', $next_link);
96 96
 		}
97 97
 
98 98
 		return $response;
@@ -105,16 +105,16 @@  discard block
 block discarded – undo
105 105
 	 * @param \WP_REST_Request $request Request object.
106 106
 	 * @return \WP_REST_Response
107 107
 	 */
108
-	public function prepare_item_for_response( $report, $request ) {
108
+	public function prepare_item_for_response($report, $request) {
109 109
 		$data = $report;
110 110
 
111
-		$context = ! empty( $request['context'] ) ? $request['context'] : 'view';
112
-		$data    = $this->add_additional_fields_to_object( $data, $request );
113
-		$data    = $this->filter_response_by_context( $data, $context );
111
+		$context = ! empty($request['context']) ? $request['context'] : 'view';
112
+		$data    = $this->add_additional_fields_to_object($data, $request);
113
+		$data    = $this->filter_response_by_context($data, $context);
114 114
 
115 115
 		// Wrap the data in a response object.
116
-		$response = rest_ensure_response( $data );
117
-		$response->add_links( $this->prepare_links( $report ) );
116
+		$response = rest_ensure_response($data);
117
+		$response->add_links($this->prepare_links($report));
118 118
 
119 119
 		/**
120 120
 		 * Filter a report returned from the API.
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
 		 * @param object           $report   The original report object.
126 126
 		 * @param \WP_REST_Request  $request  Request used to generate the response.
127 127
 		 */
128
-		return apply_filters( 'woocommerce_rest_prepare_report_categories', $response, $report, $request );
128
+		return apply_filters('woocommerce_rest_prepare_report_categories', $response, $report, $request);
129 129
 	}
130 130
 
131 131
 	/**
@@ -134,10 +134,10 @@  discard block
 block discarded – undo
134 134
 	 * @param WC_Admin_Reports_Query $object Object data.
135 135
 	 * @return array
136 136
 	 */
137
-	protected function prepare_links( $object ) {
137
+	protected function prepare_links($object) {
138 138
 		$links = array(
139 139
 			'category' => array(
140
-				'href' => rest_url( sprintf( '/%s/products/categories/%d', $this->namespace, $object['category_id'] ) ),
140
+				'href' => rest_url(sprintf('/%s/products/categories/%d', $this->namespace, $object['category_id'])),
141 141
 			),
142 142
 		);
143 143
 
@@ -156,47 +156,47 @@  discard block
 block discarded – undo
156 156
 			'type'       => 'object',
157 157
 			'properties' => array(
158 158
 				'category_id'    => array(
159
-					'description' => __( 'Category ID.', 'woocommerce' ),
159
+					'description' => __('Category ID.', 'woocommerce'),
160 160
 					'type'        => 'integer',
161
-					'context'     => array( 'view', 'edit' ),
161
+					'context'     => array('view', 'edit'),
162 162
 					'readonly'    => true,
163 163
 				),
164 164
 				'items_sold'     => array(
165
-					'description' => __( 'Amount of items sold.', 'woocommerce' ),
165
+					'description' => __('Amount of items sold.', 'woocommerce'),
166 166
 					'type'        => 'integer',
167
-					'context'     => array( 'view', 'edit' ),
167
+					'context'     => array('view', 'edit'),
168 168
 					'readonly'    => true,
169 169
 				),
170 170
 				'net_revenue'    => array(
171
-					'description' => __( 'Gross revenue.', 'woocommerce' ),
171
+					'description' => __('Gross revenue.', 'woocommerce'),
172 172
 					'type'        => 'number',
173
-					'context'     => array( 'view', 'edit' ),
173
+					'context'     => array('view', 'edit'),
174 174
 					'readonly'    => true,
175 175
 				),
176 176
 				'orders_count'   => array(
177
-					'description' => __( 'Amount of orders.', 'woocommerce' ),
177
+					'description' => __('Amount of orders.', 'woocommerce'),
178 178
 					'type'        => 'integer',
179
-					'context'     => array( 'view', 'edit' ),
179
+					'context'     => array('view', 'edit'),
180 180
 					'readonly'    => true,
181 181
 				),
182 182
 				'products_count' => array(
183
-					'description' => __( 'Amount of products.', 'woocommerce' ),
183
+					'description' => __('Amount of products.', 'woocommerce'),
184 184
 					'type'        => 'integer',
185
-					'context'     => array( 'view', 'edit' ),
185
+					'context'     => array('view', 'edit'),
186 186
 					'readonly'    => true,
187 187
 				),
188 188
 				'extended_info'  => array(
189 189
 					'name' => array(
190 190
 						'type'        => 'string',
191 191
 						'readonly'    => true,
192
-						'context'     => array( 'view', 'edit' ),
193
-						'description' => __( 'Category name.', 'woocommerce' ),
192
+						'context'     => array('view', 'edit'),
193
+						'description' => __('Category name.', 'woocommerce'),
194 194
 					),
195 195
 				),
196 196
 			),
197 197
 		);
198 198
 
199
-		return $this->add_additional_fields_schema( $schema );
199
+		return $this->add_additional_fields_schema($schema);
200 200
 	}
201 201
 
202 202
 	/**
@@ -206,17 +206,17 @@  discard block
 block discarded – undo
206 206
 	 */
207 207
 	public function get_collection_params() {
208 208
 		$params                  = array();
209
-		$params['context']       = $this->get_context_param( array( 'default' => 'view' ) );
209
+		$params['context']       = $this->get_context_param(array('default' => 'view'));
210 210
 		$params['page']          = array(
211
-			'description'       => __( 'Current page of the collection.', 'woocommerce' ),
211
+			'description'       => __('Current page of the collection.', 'woocommerce'),
212 212
 			'type'              => 'integer',
213 213
 			'default'           => 1,
214 214
 			'sanitize_callback' => 'absint',
215 215
 			'validate_callback' => 'rest_validate_request_arg',
216 216
 			'minimum'           => 1,
217 217
 		);
218
-		$params['per_page']      = array(
219
-			'description'       => __( 'Maximum number of items to be returned in result set.', 'woocommerce' ),
218
+		$params['per_page'] = array(
219
+			'description'       => __('Maximum number of items to be returned in result set.', 'woocommerce'),
220 220
 			'type'              => 'integer',
221 221
 			'default'           => 10,
222 222
 			'minimum'           => 1,
@@ -224,27 +224,27 @@  discard block
 block discarded – undo
224 224
 			'sanitize_callback' => 'absint',
225 225
 			'validate_callback' => 'rest_validate_request_arg',
226 226
 		);
227
-		$params['after']         = array(
228
-			'description'       => __( 'Limit response to resources published after a given ISO8601 compliant date.', 'woocommerce' ),
227
+		$params['after'] = array(
228
+			'description'       => __('Limit response to resources published after a given ISO8601 compliant date.', 'woocommerce'),
229 229
 			'type'              => 'string',
230 230
 			'format'            => 'date-time',
231 231
 			'validate_callback' => 'rest_validate_request_arg',
232 232
 		);
233
-		$params['before']        = array(
234
-			'description'       => __( 'Limit response to resources published before a given ISO8601 compliant date.', 'woocommerce' ),
233
+		$params['before'] = array(
234
+			'description'       => __('Limit response to resources published before a given ISO8601 compliant date.', 'woocommerce'),
235 235
 			'type'              => 'string',
236 236
 			'format'            => 'date-time',
237 237
 			'validate_callback' => 'rest_validate_request_arg',
238 238
 		);
239
-		$params['order']         = array(
240
-			'description'       => __( 'Order sort attribute ascending or descending.', 'woocommerce' ),
239
+		$params['order'] = array(
240
+			'description'       => __('Order sort attribute ascending or descending.', 'woocommerce'),
241 241
 			'type'              => 'string',
242 242
 			'default'           => 'desc',
243
-			'enum'              => array( 'asc', 'desc' ),
243
+			'enum'              => array('asc', 'desc'),
244 244
 			'validate_callback' => 'rest_validate_request_arg',
245 245
 		);
246
-		$params['orderby']       = array(
247
-			'description'       => __( 'Sort collection by object attribute.', 'woocommerce' ),
246
+		$params['orderby'] = array(
247
+			'description'       => __('Sort collection by object attribute.', 'woocommerce'),
248 248
 			'type'              => 'string',
249 249
 			'default'           => 'category_id',
250 250
 			'enum'              => array(
@@ -257,8 +257,8 @@  discard block
 block discarded – undo
257 257
 			),
258 258
 			'validate_callback' => 'rest_validate_request_arg',
259 259
 		);
260
-		$params['interval']      = array(
261
-			'description'       => __( 'Time interval to use for buckets in the returned data.', 'woocommerce' ),
260
+		$params['interval'] = array(
261
+			'description'       => __('Time interval to use for buckets in the returned data.', 'woocommerce'),
262 262
 			'type'              => 'string',
263 263
 			'default'           => 'week',
264 264
 			'enum'              => array(
@@ -271,8 +271,8 @@  discard block
 block discarded – undo
271 271
 			),
272 272
 			'validate_callback' => 'rest_validate_request_arg',
273 273
 		);
274
-		$params['status_is']     = array(
275
-			'description'       => __( 'Limit result set to items that have the specified order status.', 'woocommerce' ),
274
+		$params['status_is'] = array(
275
+			'description'       => __('Limit result set to items that have the specified order status.', 'woocommerce'),
276 276
 			'type'              => 'array',
277 277
 			'sanitize_callback' => 'wp_parse_slug_list',
278 278
 			'validate_callback' => 'rest_validate_request_arg',
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
 			),
283 283
 		);
284 284
 		$params['status_is_not'] = array(
285
-			'description'       => __( 'Limit result set to items that don\'t have the specified order status.', 'woocommerce' ),
285
+			'description'       => __('Limit result set to items that don\'t have the specified order status.', 'woocommerce'),
286 286
 			'type'              => 'array',
287 287
 			'sanitize_callback' => 'wp_parse_slug_list',
288 288
 			'validate_callback' => 'rest_validate_request_arg',
@@ -291,8 +291,8 @@  discard block
 block discarded – undo
291 291
 				'type' => 'string',
292 292
 			),
293 293
 		);
294
-		$params['categories']    = array(
295
-			'description'       => __( 'Limit result set to all items that have the specified term assigned in the categories taxonomy.', 'woocommerce' ),
294
+		$params['categories'] = array(
295
+			'description'       => __('Limit result set to all items that have the specified term assigned in the categories taxonomy.', 'woocommerce'),
296 296
 			'type'              => 'array',
297 297
 			'sanitize_callback' => 'wp_parse_id_list',
298 298
 			'validate_callback' => 'rest_validate_request_arg',
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
 			),
302 302
 		);
303 303
 		$params['extended_info'] = array(
304
-			'description'       => __( 'Add additional piece of info about each category to the report.', 'woocommerce' ),
304
+			'description'       => __('Add additional piece of info about each category to the report.', 'woocommerce'),
305 305
 			'type'              => 'boolean',
306 306
 			'default'           => false,
307 307
 			'sanitize_callback' => 'wc_string_to_bool',
Please login to merge, or discard this patch.
src/RestApi/Version4/Controllers/Reports/DownloadStats.php 1 patch
Spacing   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
 
10 10
 namespace WooCommerce\RestApi\Version4\Controllers\Reports;
11 11
 
12
-defined( 'ABSPATH' ) || exit;
12
+defined('ABSPATH') || exit;
13 13
 
14 14
 use \WooCommerce\RestApi\Version4\Controllers\Reports as Reports;
15 15
 
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 	 * @param array $request Request array.
32 32
 	 * @return array
33 33
 	 */
34
-	protected function prepare_reports_query( $request ) {
34
+	protected function prepare_reports_query($request) {
35 35
 		$args                        = array();
36 36
 		$args['before']              = $request['before'];
37 37
 		$args['after']               = $request['after'];
@@ -59,40 +59,40 @@  discard block
 block discarded – undo
59 59
 	 * @param \WP_REST_Request $request Request data.
60 60
 	 * @return array|\WP_Error
61 61
 	 */
62
-	public function get_items( $request ) {
63
-		$query_args      = $this->prepare_reports_query( $request );
64
-		$downloads_query = new \WC_Admin_Reports_Downloads_Stats_Query( $query_args );
62
+	public function get_items($request) {
63
+		$query_args      = $this->prepare_reports_query($request);
64
+		$downloads_query = new \WC_Admin_Reports_Downloads_Stats_Query($query_args);
65 65
 		$report_data     = $downloads_query->get_data();
66 66
 
67 67
 		$out_data = array(
68
-			'totals'    => get_object_vars( $report_data->totals ),
68
+			'totals'    => get_object_vars($report_data->totals),
69 69
 			'intervals' => array(),
70 70
 		);
71 71
 
72
-		foreach ( $report_data->intervals as $interval_data ) {
73
-			$item                    = $this->prepare_item_for_response( $interval_data, $request );
74
-			$out_data['intervals'][] = $this->prepare_response_for_collection( $item );
72
+		foreach ($report_data->intervals as $interval_data) {
73
+			$item                    = $this->prepare_item_for_response($interval_data, $request);
74
+			$out_data['intervals'][] = $this->prepare_response_for_collection($item);
75 75
 		}
76 76
 
77
-		$response = rest_ensure_response( $out_data );
78
-		$response->header( 'X-WP-Total', (int) $report_data->total );
79
-		$response->header( 'X-WP-TotalPages', (int) $report_data->pages );
77
+		$response = rest_ensure_response($out_data);
78
+		$response->header('X-WP-Total', (int) $report_data->total);
79
+		$response->header('X-WP-TotalPages', (int) $report_data->pages);
80 80
 
81 81
 		$page      = $report_data->page_no;
82 82
 		$max_pages = $report_data->pages;
83
-		$base      = add_query_arg( $request->get_query_params(), rest_url( sprintf( '/%s/%s', $this->namespace, $this->rest_base ) ) );
84
-		if ( $page > 1 ) {
83
+		$base      = add_query_arg($request->get_query_params(), rest_url(sprintf('/%s/%s', $this->namespace, $this->rest_base)));
84
+		if ($page > 1) {
85 85
 			$prev_page = $page - 1;
86
-			if ( $prev_page > $max_pages ) {
86
+			if ($prev_page > $max_pages) {
87 87
 				$prev_page = $max_pages;
88 88
 			}
89
-			$prev_link = add_query_arg( 'page', $prev_page, $base );
90
-			$response->link_header( 'prev', $prev_link );
89
+			$prev_link = add_query_arg('page', $prev_page, $base);
90
+			$response->link_header('prev', $prev_link);
91 91
 		}
92
-		if ( $max_pages > $page ) {
92
+		if ($max_pages > $page) {
93 93
 			$next_page = $page + 1;
94
-			$next_link = add_query_arg( 'page', $next_page, $base );
95
-			$response->link_header( 'next', $next_link );
94
+			$next_link = add_query_arg('page', $next_page, $base);
95
+			$response->link_header('next', $next_link);
96 96
 		}
97 97
 
98 98
 		return $response;
@@ -105,15 +105,15 @@  discard block
 block discarded – undo
105 105
 	 * @param \WP_REST_Request $request Request object.
106 106
 	 * @return \WP_REST_Response
107 107
 	 */
108
-	public function prepare_item_for_response( $report, $request ) {
108
+	public function prepare_item_for_response($report, $request) {
109 109
 		$data = $report;
110 110
 
111
-		$context = ! empty( $request['context'] ) ? $request['context'] : 'view';
112
-		$data    = $this->add_additional_fields_to_object( $data, $request );
113
-		$data    = $this->filter_response_by_context( $data, $context );
111
+		$context = ! empty($request['context']) ? $request['context'] : 'view';
112
+		$data    = $this->add_additional_fields_to_object($data, $request);
113
+		$data    = $this->filter_response_by_context($data, $context);
114 114
 
115 115
 		// Wrap the data in a response object.
116
-		$response = rest_ensure_response( $data );
116
+		$response = rest_ensure_response($data);
117 117
 
118 118
 		/**
119 119
 		 * Filter a report returned from the API.
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 		 * @param object           $report   The original report object.
125 125
 		 * @param \WP_REST_Request  $request  Request used to generate the response.
126 126
 		 */
127
-		return apply_filters( 'woocommerce_rest_prepare_report_downloads_stats', $response, $report, $request );
127
+		return apply_filters('woocommerce_rest_prepare_report_downloads_stats', $response, $report, $request);
128 128
 	}
129 129
 
130 130
 	/**
@@ -135,9 +135,9 @@  discard block
 block discarded – undo
135 135
 	public function get_item_schema() {
136 136
 		$totals = array(
137 137
 			'download_count' => array(
138
-				'description' => __( 'Number of downloads.', 'woocommerce' ),
138
+				'description' => __('Number of downloads.', 'woocommerce'),
139 139
 				'type'        => 'number',
140
-				'context'     => array( 'view', 'edit' ),
140
+				'context'     => array('view', 'edit'),
141 141
 				'readonly'    => true,
142 142
 				'indicator'   => true,
143 143
 			),
@@ -149,55 +149,55 @@  discard block
 block discarded – undo
149 149
 			'type'       => 'object',
150 150
 			'properties' => array(
151 151
 				'totals'    => array(
152
-					'description' => __( 'Totals data.', 'woocommerce' ),
152
+					'description' => __('Totals data.', 'woocommerce'),
153 153
 					'type'        => 'object',
154
-					'context'     => array( 'view', 'edit' ),
154
+					'context'     => array('view', 'edit'),
155 155
 					'readonly'    => true,
156 156
 					'properties'  => $totals,
157 157
 				),
158 158
 				'intervals' => array(
159
-					'description' => __( 'Reports data grouped by intervals.', 'woocommerce' ),
159
+					'description' => __('Reports data grouped by intervals.', 'woocommerce'),
160 160
 					'type'        => 'array',
161
-					'context'     => array( 'view', 'edit' ),
161
+					'context'     => array('view', 'edit'),
162 162
 					'readonly'    => true,
163 163
 					'items'       => array(
164 164
 						'type'       => 'object',
165 165
 						'properties' => array(
166 166
 							'interval'       => array(
167
-								'description' => __( 'Type of interval.', 'woocommerce' ),
167
+								'description' => __('Type of interval.', 'woocommerce'),
168 168
 								'type'        => 'string',
169
-								'context'     => array( 'view', 'edit' ),
169
+								'context'     => array('view', 'edit'),
170 170
 								'readonly'    => true,
171
-								'enum'        => array( 'day', 'week', 'month', 'year' ),
171
+								'enum'        => array('day', 'week', 'month', 'year'),
172 172
 							),
173 173
 							'date_start'     => array(
174
-								'description' => __( "The date the report start, in the site's timezone.", 'woocommerce' ),
174
+								'description' => __("The date the report start, in the site's timezone.", 'woocommerce'),
175 175
 								'type'        => 'date-time',
176
-								'context'     => array( 'view', 'edit' ),
176
+								'context'     => array('view', 'edit'),
177 177
 								'readonly'    => true,
178 178
 							),
179 179
 							'date_start_gmt' => array(
180
-								'description' => __( 'The date the report start, as GMT.', 'woocommerce' ),
180
+								'description' => __('The date the report start, as GMT.', 'woocommerce'),
181 181
 								'type'        => 'date-time',
182
-								'context'     => array( 'view', 'edit' ),
182
+								'context'     => array('view', 'edit'),
183 183
 								'readonly'    => true,
184 184
 							),
185 185
 							'date_end'       => array(
186
-								'description' => __( "The date the report end, in the site's timezone.", 'woocommerce' ),
186
+								'description' => __("The date the report end, in the site's timezone.", 'woocommerce'),
187 187
 								'type'        => 'date-time',
188
-								'context'     => array( 'view', 'edit' ),
188
+								'context'     => array('view', 'edit'),
189 189
 								'readonly'    => true,
190 190
 							),
191 191
 							'date_end_gmt'   => array(
192
-								'description' => __( 'The date the report end, as GMT.', 'woocommerce' ),
192
+								'description' => __('The date the report end, as GMT.', 'woocommerce'),
193 193
 								'type'        => 'date-time',
194
-								'context'     => array( 'view', 'edit' ),
194
+								'context'     => array('view', 'edit'),
195 195
 								'readonly'    => true,
196 196
 							),
197 197
 							'subtotals'      => array(
198
-								'description' => __( 'Interval subtotals.', 'woocommerce' ),
198
+								'description' => __('Interval subtotals.', 'woocommerce'),
199 199
 								'type'        => 'object',
200
-								'context'     => array( 'view', 'edit' ),
200
+								'context'     => array('view', 'edit'),
201 201
 								'readonly'    => true,
202 202
 								'properties'  => $totals,
203 203
 							),
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
 			),
208 208
 		);
209 209
 
210
-		return $this->add_additional_fields_schema( $schema );
210
+		return $this->add_additional_fields_schema($schema);
211 211
 	}
212 212
 
213 213
 	/**
@@ -217,17 +217,17 @@  discard block
 block discarded – undo
217 217
 	 */
218 218
 	public function get_collection_params() {
219 219
 		$params                     = array();
220
-		$params['context']          = $this->get_context_param( array( 'default' => 'view' ) );
220
+		$params['context']          = $this->get_context_param(array('default' => 'view'));
221 221
 		$params['page']             = array(
222
-			'description'       => __( 'Current page of the collection.', 'woocommerce' ),
222
+			'description'       => __('Current page of the collection.', 'woocommerce'),
223 223
 			'type'              => 'integer',
224 224
 			'default'           => 1,
225 225
 			'sanitize_callback' => 'absint',
226 226
 			'validate_callback' => 'rest_validate_request_arg',
227 227
 			'minimum'           => 1,
228 228
 		);
229
-		$params['per_page']         = array(
230
-			'description'       => __( 'Maximum number of items to be returned in result set.', 'woocommerce' ),
229
+		$params['per_page'] = array(
230
+			'description'       => __('Maximum number of items to be returned in result set.', 'woocommerce'),
231 231
 			'type'              => 'integer',
232 232
 			'default'           => 10,
233 233
 			'minimum'           => 1,
@@ -235,27 +235,27 @@  discard block
 block discarded – undo
235 235
 			'sanitize_callback' => 'absint',
236 236
 			'validate_callback' => 'rest_validate_request_arg',
237 237
 		);
238
-		$params['after']            = array(
239
-			'description'       => __( 'Limit response to resources published after a given ISO8601 compliant date.', 'woocommerce' ),
238
+		$params['after'] = array(
239
+			'description'       => __('Limit response to resources published after a given ISO8601 compliant date.', 'woocommerce'),
240 240
 			'type'              => 'string',
241 241
 			'format'            => 'date-time',
242 242
 			'validate_callback' => 'rest_validate_request_arg',
243 243
 		);
244
-		$params['before']           = array(
245
-			'description'       => __( 'Limit response to resources published before a given ISO8601 compliant date.', 'woocommerce' ),
244
+		$params['before'] = array(
245
+			'description'       => __('Limit response to resources published before a given ISO8601 compliant date.', 'woocommerce'),
246 246
 			'type'              => 'string',
247 247
 			'format'            => 'date-time',
248 248
 			'validate_callback' => 'rest_validate_request_arg',
249 249
 		);
250
-		$params['order']            = array(
251
-			'description'       => __( 'Order sort attribute ascending or descending.', 'woocommerce' ),
250
+		$params['order'] = array(
251
+			'description'       => __('Order sort attribute ascending or descending.', 'woocommerce'),
252 252
 			'type'              => 'string',
253 253
 			'default'           => 'desc',
254
-			'enum'              => array( 'asc', 'desc' ),
254
+			'enum'              => array('asc', 'desc'),
255 255
 			'validate_callback' => 'rest_validate_request_arg',
256 256
 		);
257
-		$params['orderby']          = array(
258
-			'description'       => __( 'Sort collection by object attribute.', 'woocommerce' ),
257
+		$params['orderby'] = array(
258
+			'description'       => __('Sort collection by object attribute.', 'woocommerce'),
259 259
 			'type'              => 'string',
260 260
 			'default'           => 'date',
261 261
 			'enum'              => array(
@@ -264,8 +264,8 @@  discard block
 block discarded – undo
264 264
 			),
265 265
 			'validate_callback' => 'rest_validate_request_arg',
266 266
 		);
267
-		$params['interval']         = array(
268
-			'description'       => __( 'Time interval to use for buckets in the returned data.', 'woocommerce' ),
267
+		$params['interval'] = array(
268
+			'description'       => __('Time interval to use for buckets in the returned data.', 'woocommerce'),
269 269
 			'type'              => 'string',
270 270
 			'default'           => 'week',
271 271
 			'enum'              => array(
@@ -278,8 +278,8 @@  discard block
 block discarded – undo
278 278
 			),
279 279
 			'validate_callback' => 'rest_validate_request_arg',
280 280
 		);
281
-		$params['match']            = array(
282
-			'description'       => __( 'Indicates whether all the conditions should be true for the resulting set, or if any one of them is sufficient. Match affects the following parameters: status_is, status_is_not, product_includes, product_excludes, coupon_includes, coupon_excludes, customer, categories', 'woocommerce' ),
281
+		$params['match'] = array(
282
+			'description'       => __('Indicates whether all the conditions should be true for the resulting set, or if any one of them is sufficient. Match affects the following parameters: status_is, status_is_not, product_includes, product_excludes, coupon_includes, coupon_excludes, customer, categories', 'woocommerce'),
283 283
 			'type'              => 'string',
284 284
 			'default'           => 'all',
285 285
 			'enum'              => array(
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
 			'validate_callback' => 'rest_validate_request_arg',
290 290
 		);
291 291
 		$params['product_includes'] = array(
292
-			'description'       => __( 'Limit result set to items that have the specified product(s) assigned.', 'woocommerce' ),
292
+			'description'       => __('Limit result set to items that have the specified product(s) assigned.', 'woocommerce'),
293 293
 			'type'              => 'array',
294 294
 			'items'             => array(
295 295
 				'type' => 'integer',
@@ -298,8 +298,8 @@  discard block
 block discarded – undo
298 298
 			'sanitize_callback' => 'wp_parse_id_list',
299 299
 
300 300
 		);
301
-		$params['product_excludes']    = array(
302
-			'description'       => __( 'Limit result set to items that don\'t have the specified product(s) assigned.', 'woocommerce' ),
301
+		$params['product_excludes'] = array(
302
+			'description'       => __('Limit result set to items that don\'t have the specified product(s) assigned.', 'woocommerce'),
303 303
 			'type'              => 'array',
304 304
 			'items'             => array(
305 305
 				'type' => 'integer',
@@ -307,8 +307,8 @@  discard block
 block discarded – undo
307 307
 			'default'           => array(),
308 308
 			'sanitize_callback' => 'wp_parse_id_list',
309 309
 		);
310
-		$params['order_includes']      = array(
311
-			'description'       => __( 'Limit result set to items that have the specified order ids.', 'woocommerce' ),
310
+		$params['order_includes'] = array(
311
+			'description'       => __('Limit result set to items that have the specified order ids.', 'woocommerce'),
312 312
 			'type'              => 'array',
313 313
 			'sanitize_callback' => 'wp_parse_id_list',
314 314
 			'validate_callback' => 'rest_validate_request_arg',
@@ -316,8 +316,8 @@  discard block
 block discarded – undo
316 316
 				'type' => 'integer',
317 317
 			),
318 318
 		);
319
-		$params['order_excludes']      = array(
320
-			'description'       => __( 'Limit result set to items that don\'t have the specified order ids.', 'woocommerce' ),
319
+		$params['order_excludes'] = array(
320
+			'description'       => __('Limit result set to items that don\'t have the specified order ids.', 'woocommerce'),
321 321
 			'type'              => 'array',
322 322
 			'sanitize_callback' => 'wp_parse_id_list',
323 323
 			'validate_callback' => 'rest_validate_request_arg',
@@ -325,8 +325,8 @@  discard block
 block discarded – undo
325 325
 				'type' => 'integer',
326 326
 			),
327 327
 		);
328
-		$params['customer_includes']   = array(
329
-			'description'       => __( 'Limit response to objects that have the specified customer ids.', 'woocommerce' ),
328
+		$params['customer_includes'] = array(
329
+			'description'       => __('Limit response to objects that have the specified customer ids.', 'woocommerce'),
330 330
 			'type'              => 'array',
331 331
 			'sanitize_callback' => 'wp_parse_id_list',
332 332
 			'validate_callback' => 'rest_validate_request_arg',
@@ -334,8 +334,8 @@  discard block
 block discarded – undo
334 334
 				'type' => 'integer',
335 335
 			),
336 336
 		);
337
-		$params['customer_excludes']   = array(
338
-			'description'       => __( 'Limit response to objects that don\'t have the specified customer ids.', 'woocommerce' ),
337
+		$params['customer_excludes'] = array(
338
+			'description'       => __('Limit response to objects that don\'t have the specified customer ids.', 'woocommerce'),
339 339
 			'type'              => 'array',
340 340
 			'sanitize_callback' => 'wp_parse_id_list',
341 341
 			'validate_callback' => 'rest_validate_request_arg',
@@ -344,7 +344,7 @@  discard block
 block discarded – undo
344 344
 			),
345 345
 		);
346 346
 		$params['ip_address_includes'] = array(
347
-			'description'       => __( 'Limit response to objects that have a specified ip address.', 'woocommerce' ),
347
+			'description'       => __('Limit response to objects that have a specified ip address.', 'woocommerce'),
348 348
 			'type'              => 'array',
349 349
 			'validate_callback' => 'rest_validate_request_arg',
350 350
 			'items'             => array(
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
 		);
354 354
 
355 355
 		$params['ip_address_excludes'] = array(
356
-			'description'       => __( 'Limit response to objects that don\'t have a specified ip address.', 'woocommerce' ),
356
+			'description'       => __('Limit response to objects that don\'t have a specified ip address.', 'woocommerce'),
357 357
 			'type'              => 'array',
358 358
 			'validate_callback' => 'rest_validate_request_arg',
359 359
 			'items'             => array(
Please login to merge, or discard this patch.
src/RestApi/Version4/Controllers/Reports/CouponStats.php 1 patch
Spacing   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
 
10 10
 namespace WooCommerce\RestApi\Version4\Controllers\Reports;
11 11
 
12
-defined( 'ABSPATH' ) || exit;
12
+defined('ABSPATH') || exit;
13 13
 
14 14
 use \WooCommerce\RestApi\Version4\Controllers\Reports as Reports;
15 15
 
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 	 * @param array $request Request array.
32 32
 	 * @return array
33 33
 	 */
34
-	protected function prepare_reports_query( $request ) {
34
+	protected function prepare_reports_query($request) {
35 35
 		$args              = array();
36 36
 		$args['before']    = $request['before'];
37 37
 		$args['after']     = $request['after'];
@@ -52,44 +52,44 @@  discard block
 block discarded – undo
52 52
 	 * @param \WP_REST_Request $request Request data.
53 53
 	 * @return array|\WP_Error
54 54
 	 */
55
-	public function get_items( $request ) {
56
-		$query_args    = $this->prepare_reports_query( $request );
57
-		$coupons_query = new \WC_Admin_Reports_Coupons_Stats_Query( $query_args );
55
+	public function get_items($request) {
56
+		$query_args    = $this->prepare_reports_query($request);
57
+		$coupons_query = new \WC_Admin_Reports_Coupons_Stats_Query($query_args);
58 58
 		try {
59 59
 			$report_data = $coupons_query->get_data();
60
-		} catch ( \WC_Admin_Reports_Parameter_Exception $e ) {
61
-			return new \WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) );
60
+		} catch (\WC_Admin_Reports_Parameter_Exception $e) {
61
+			return new \WP_Error($e->getErrorCode(), $e->getMessage(), array('status' => $e->getCode()));
62 62
 		}
63 63
 
64 64
 		$out_data = array(
65
-			'totals'    => get_object_vars( $report_data->totals ),
65
+			'totals'    => get_object_vars($report_data->totals),
66 66
 			'intervals' => array(),
67 67
 		);
68 68
 
69
-		foreach ( $report_data->intervals as $interval_data ) {
70
-			$item                    = $this->prepare_item_for_response( (object) $interval_data, $request );
71
-			$out_data['intervals'][] = $this->prepare_response_for_collection( $item );
69
+		foreach ($report_data->intervals as $interval_data) {
70
+			$item                    = $this->prepare_item_for_response((object) $interval_data, $request);
71
+			$out_data['intervals'][] = $this->prepare_response_for_collection($item);
72 72
 		}
73 73
 
74
-		$response = rest_ensure_response( $out_data );
75
-		$response->header( 'X-WP-Total', (int) $report_data->total );
76
-		$response->header( 'X-WP-TotalPages', (int) $report_data->pages );
74
+		$response = rest_ensure_response($out_data);
75
+		$response->header('X-WP-Total', (int) $report_data->total);
76
+		$response->header('X-WP-TotalPages', (int) $report_data->pages);
77 77
 
78 78
 		$page      = $report_data->page_no;
79 79
 		$max_pages = $report_data->pages;
80
-		$base      = add_query_arg( $request->get_query_params(), rest_url( sprintf( '/%s/%s', $this->namespace, $this->rest_base ) ) );
81
-		if ( $page > 1 ) {
80
+		$base      = add_query_arg($request->get_query_params(), rest_url(sprintf('/%s/%s', $this->namespace, $this->rest_base)));
81
+		if ($page > 1) {
82 82
 			$prev_page = $page - 1;
83
-			if ( $prev_page > $max_pages ) {
83
+			if ($prev_page > $max_pages) {
84 84
 				$prev_page = $max_pages;
85 85
 			}
86
-			$prev_link = add_query_arg( 'page', $prev_page, $base );
87
-			$response->link_header( 'prev', $prev_link );
86
+			$prev_link = add_query_arg('page', $prev_page, $base);
87
+			$response->link_header('prev', $prev_link);
88 88
 		}
89
-		if ( $max_pages > $page ) {
89
+		if ($max_pages > $page) {
90 90
 			$next_page = $page + 1;
91
-			$next_link = add_query_arg( 'page', $next_page, $base );
92
-			$response->link_header( 'next', $next_link );
91
+			$next_link = add_query_arg('page', $next_page, $base);
92
+			$response->link_header('next', $next_link);
93 93
 		}
94 94
 
95 95
 		return $response;
@@ -102,15 +102,15 @@  discard block
 block discarded – undo
102 102
 	 * @param \WP_REST_Request $request Request object.
103 103
 	 * @return \WP_REST_Response
104 104
 	 */
105
-	public function prepare_item_for_response( $report, $request ) {
106
-		$data = get_object_vars( $report );
105
+	public function prepare_item_for_response($report, $request) {
106
+		$data = get_object_vars($report);
107 107
 
108
-		$context = ! empty( $request['context'] ) ? $request['context'] : 'view';
109
-		$data    = $this->add_additional_fields_to_object( $data, $request );
110
-		$data    = $this->filter_response_by_context( $data, $context );
108
+		$context = ! empty($request['context']) ? $request['context'] : 'view';
109
+		$data    = $this->add_additional_fields_to_object($data, $request);
110
+		$data    = $this->filter_response_by_context($data, $context);
111 111
 
112 112
 		// Wrap the data in a response object.
113
-		$response = rest_ensure_response( $data );
113
+		$response = rest_ensure_response($data);
114 114
 
115 115
 		/**
116 116
 		 * Filter a report returned from the API.
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 		 * @param object           $report   The original report object.
122 122
 		 * @param \WP_REST_Request  $request  Request used to generate the response.
123 123
 		 */
124
-		return apply_filters( 'woocommerce_rest_prepare_report_coupons_stats', $response, $report, $request );
124
+		return apply_filters('woocommerce_rest_prepare_report_coupons_stats', $response, $report, $request);
125 125
 	}
126 126
 
127 127
 	/**
@@ -132,23 +132,23 @@  discard block
 block discarded – undo
132 132
 	public function get_item_schema() {
133 133
 		$data_values = array(
134 134
 			'amount'        => array(
135
-				'description' => __( 'Net discount amount.', 'woocommerce' ),
135
+				'description' => __('Net discount amount.', 'woocommerce'),
136 136
 				'type'        => 'number',
137
-				'context'     => array( 'view', 'edit' ),
137
+				'context'     => array('view', 'edit'),
138 138
 				'readonly'    => true,
139 139
 				'indicator'   => true,
140 140
 				'format'      => 'currency',
141 141
 			),
142 142
 			'coupons_count' => array(
143
-				'description' => __( 'Amount of coupons.', 'woocommerce' ),
143
+				'description' => __('Amount of coupons.', 'woocommerce'),
144 144
 				'type'        => 'integer',
145
-				'context'     => array( 'view', 'edit' ),
145
+				'context'     => array('view', 'edit'),
146 146
 				'readonly'    => true,
147 147
 			),
148 148
 			'orders_count'  => array(
149
-				'description' => __( 'Amount of discounted orders.', 'woocommerce' ),
149
+				'description' => __('Amount of discounted orders.', 'woocommerce'),
150 150
 				'type'        => 'integer',
151
-				'context'     => array( 'view', 'edit' ),
151
+				'context'     => array('view', 'edit'),
152 152
 				'readonly'    => true,
153 153
 				'indicator'   => true,
154 154
 			),
@@ -156,23 +156,23 @@  discard block
 block discarded – undo
156 156
 
157 157
 		$segments = array(
158 158
 			'segments' => array(
159
-				'description' => __( 'Reports data grouped by segment condition.', 'woocommerce' ),
159
+				'description' => __('Reports data grouped by segment condition.', 'woocommerce'),
160 160
 				'type'        => 'array',
161
-				'context'     => array( 'view', 'edit' ),
161
+				'context'     => array('view', 'edit'),
162 162
 				'readonly'    => true,
163 163
 				'items'       => array(
164 164
 					'type'       => 'object',
165 165
 					'properties' => array(
166 166
 						'segment_id' => array(
167
-							'description' => __( 'Segment identificator.', 'woocommerce' ),
167
+							'description' => __('Segment identificator.', 'woocommerce'),
168 168
 							'type'        => 'integer',
169
-							'context'     => array( 'view', 'edit' ),
169
+							'context'     => array('view', 'edit'),
170 170
 							'readonly'    => true,
171 171
 						),
172 172
 						'subtotals'  => array(
173
-							'description' => __( 'Interval subtotals.', 'woocommerce' ),
173
+							'description' => __('Interval subtotals.', 'woocommerce'),
174 174
 							'type'        => 'object',
175
-							'context'     => array( 'view', 'edit' ),
175
+							'context'     => array('view', 'edit'),
176 176
 							'readonly'    => true,
177 177
 							'properties'  => $data_values,
178 178
 						),
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 			),
182 182
 		);
183 183
 
184
-		$totals = array_merge( $data_values, $segments );
184
+		$totals = array_merge($data_values, $segments);
185 185
 
186 186
 		$schema = array(
187 187
 			'$schema'    => 'http://json-schema.org/draft-04/schema#',
@@ -189,55 +189,55 @@  discard block
 block discarded – undo
189 189
 			'type'       => 'object',
190 190
 			'properties' => array(
191 191
 				'totals'    => array(
192
-					'description' => __( 'Totals data.', 'woocommerce' ),
192
+					'description' => __('Totals data.', 'woocommerce'),
193 193
 					'type'        => 'object',
194
-					'context'     => array( 'view', 'edit' ),
194
+					'context'     => array('view', 'edit'),
195 195
 					'readonly'    => true,
196 196
 					'properties'  => $totals,
197 197
 				),
198 198
 				'intervals' => array(
199
-					'description' => __( 'Reports data grouped by intervals.', 'woocommerce' ),
199
+					'description' => __('Reports data grouped by intervals.', 'woocommerce'),
200 200
 					'type'        => 'array',
201
-					'context'     => array( 'view', 'edit' ),
201
+					'context'     => array('view', 'edit'),
202 202
 					'readonly'    => true,
203 203
 					'items'       => array(
204 204
 						'type'       => 'object',
205 205
 						'properties' => array(
206 206
 							'interval'       => array(
207
-								'description' => __( 'Type of interval.', 'woocommerce' ),
207
+								'description' => __('Type of interval.', 'woocommerce'),
208 208
 								'type'        => 'string',
209
-								'context'     => array( 'view', 'edit' ),
209
+								'context'     => array('view', 'edit'),
210 210
 								'readonly'    => true,
211
-								'enum'        => array( 'day', 'week', 'month', 'year' ),
211
+								'enum'        => array('day', 'week', 'month', 'year'),
212 212
 							),
213 213
 							'date_start'     => array(
214
-								'description' => __( "The date the report start, in the site's timezone.", 'woocommerce' ),
214
+								'description' => __("The date the report start, in the site's timezone.", 'woocommerce'),
215 215
 								'type'        => 'date-time',
216
-								'context'     => array( 'view', 'edit' ),
216
+								'context'     => array('view', 'edit'),
217 217
 								'readonly'    => true,
218 218
 							),
219 219
 							'date_start_gmt' => array(
220
-								'description' => __( 'The date the report start, as GMT.', 'woocommerce' ),
220
+								'description' => __('The date the report start, as GMT.', 'woocommerce'),
221 221
 								'type'        => 'date-time',
222
-								'context'     => array( 'view', 'edit' ),
222
+								'context'     => array('view', 'edit'),
223 223
 								'readonly'    => true,
224 224
 							),
225 225
 							'date_end'       => array(
226
-								'description' => __( "The date the report end, in the site's timezone.", 'woocommerce' ),
226
+								'description' => __("The date the report end, in the site's timezone.", 'woocommerce'),
227 227
 								'type'        => 'date-time',
228
-								'context'     => array( 'view', 'edit' ),
228
+								'context'     => array('view', 'edit'),
229 229
 								'readonly'    => true,
230 230
 							),
231 231
 							'date_end_gmt'   => array(
232
-								'description' => __( 'The date the report end, as GMT.', 'woocommerce' ),
232
+								'description' => __('The date the report end, as GMT.', 'woocommerce'),
233 233
 								'type'        => 'date-time',
234
-								'context'     => array( 'view', 'edit' ),
234
+								'context'     => array('view', 'edit'),
235 235
 								'readonly'    => true,
236 236
 							),
237 237
 							'subtotals'      => array(
238
-								'description' => __( 'Interval subtotals.', 'woocommerce' ),
238
+								'description' => __('Interval subtotals.', 'woocommerce'),
239 239
 								'type'        => 'object',
240
-								'context'     => array( 'view', 'edit' ),
240
+								'context'     => array('view', 'edit'),
241 241
 								'readonly'    => true,
242 242
 								'properties'  => $totals,
243 243
 							),
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
 			),
248 248
 		);
249 249
 
250
-		return $this->add_additional_fields_schema( $schema );
250
+		return $this->add_additional_fields_schema($schema);
251 251
 	}
252 252
 
253 253
 	/**
@@ -257,17 +257,17 @@  discard block
 block discarded – undo
257 257
 	 */
258 258
 	public function get_collection_params() {
259 259
 		$params              = array();
260
-		$params['context']   = $this->get_context_param( array( 'default' => 'view' ) );
260
+		$params['context']   = $this->get_context_param(array('default' => 'view'));
261 261
 		$params['page']      = array(
262
-			'description'       => __( 'Current page of the collection.', 'woocommerce' ),
262
+			'description'       => __('Current page of the collection.', 'woocommerce'),
263 263
 			'type'              => 'integer',
264 264
 			'default'           => 1,
265 265
 			'sanitize_callback' => 'absint',
266 266
 			'validate_callback' => 'rest_validate_request_arg',
267 267
 			'minimum'           => 1,
268 268
 		);
269
-		$params['per_page']  = array(
270
-			'description'       => __( 'Maximum number of items to be returned in result set.', 'woocommerce' ),
269
+		$params['per_page'] = array(
270
+			'description'       => __('Maximum number of items to be returned in result set.', 'woocommerce'),
271 271
 			'type'              => 'integer',
272 272
 			'default'           => 10,
273 273
 			'minimum'           => 1,
@@ -275,27 +275,27 @@  discard block
 block discarded – undo
275 275
 			'sanitize_callback' => 'absint',
276 276
 			'validate_callback' => 'rest_validate_request_arg',
277 277
 		);
278
-		$params['after']     = array(
279
-			'description'       => __( 'Limit response to resources published after a given ISO8601 compliant date.', 'woocommerce' ),
278
+		$params['after'] = array(
279
+			'description'       => __('Limit response to resources published after a given ISO8601 compliant date.', 'woocommerce'),
280 280
 			'type'              => 'string',
281 281
 			'format'            => 'date-time',
282 282
 			'validate_callback' => 'rest_validate_request_arg',
283 283
 		);
284
-		$params['before']    = array(
285
-			'description'       => __( 'Limit response to resources published before a given ISO8601 compliant date.', 'woocommerce' ),
284
+		$params['before'] = array(
285
+			'description'       => __('Limit response to resources published before a given ISO8601 compliant date.', 'woocommerce'),
286 286
 			'type'              => 'string',
287 287
 			'format'            => 'date-time',
288 288
 			'validate_callback' => 'rest_validate_request_arg',
289 289
 		);
290
-		$params['order']     = array(
291
-			'description'       => __( 'Order sort attribute ascending or descending.', 'woocommerce' ),
290
+		$params['order'] = array(
291
+			'description'       => __('Order sort attribute ascending or descending.', 'woocommerce'),
292 292
 			'type'              => 'string',
293 293
 			'default'           => 'desc',
294
-			'enum'              => array( 'asc', 'desc' ),
294
+			'enum'              => array('asc', 'desc'),
295 295
 			'validate_callback' => 'rest_validate_request_arg',
296 296
 		);
297
-		$params['orderby']   = array(
298
-			'description'       => __( 'Sort collection by object attribute.', 'woocommerce' ),
297
+		$params['orderby'] = array(
298
+			'description'       => __('Sort collection by object attribute.', 'woocommerce'),
299 299
 			'type'              => 'string',
300 300
 			'default'           => 'date',
301 301
 			'enum'              => array(
@@ -306,8 +306,8 @@  discard block
 block discarded – undo
306 306
 			),
307 307
 			'validate_callback' => 'rest_validate_request_arg',
308 308
 		);
309
-		$params['interval']  = array(
310
-			'description'       => __( 'Time interval to use for buckets in the returned data.', 'woocommerce' ),
309
+		$params['interval'] = array(
310
+			'description'       => __('Time interval to use for buckets in the returned data.', 'woocommerce'),
311 311
 			'type'              => 'string',
312 312
 			'default'           => 'week',
313 313
 			'enum'              => array(
@@ -320,8 +320,8 @@  discard block
 block discarded – undo
320 320
 			),
321 321
 			'validate_callback' => 'rest_validate_request_arg',
322 322
 		);
323
-		$params['coupons']   = array(
324
-			'description'       => __( 'Limit result set to coupons assigned specific coupon IDs.', 'woocommerce' ),
323
+		$params['coupons'] = array(
324
+			'description'       => __('Limit result set to coupons assigned specific coupon IDs.', 'woocommerce'),
325 325
 			'type'              => 'array',
326 326
 			'sanitize_callback' => 'wp_parse_id_list',
327 327
 			'validate_callback' => 'rest_validate_request_arg',
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
 			),
331 331
 		);
332 332
 		$params['segmentby'] = array(
333
-			'description'       => __( 'Segment the response by additional constraint.', 'woocommerce' ),
333
+			'description'       => __('Segment the response by additional constraint.', 'woocommerce'),
334 334
 			'type'              => 'string',
335 335
 			'enum'              => array(
336 336
 				'product',
Please login to merge, or discard this patch.
src/RestApi/Version4/Controllers/Reports/StockStats.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
 
10 10
 namespace WooCommerce\RestApi\Version4\Controllers\Reports;
11 11
 
12
-defined( 'ABSPATH' ) || exit;
12
+defined('ABSPATH') || exit;
13 13
 
14 14
 use \WooCommerce\RestApi\Version4\Controllers\Reports as Reports;
15 15
 
@@ -31,13 +31,13 @@  discard block
 block discarded – undo
31 31
 	 * @param  \WP_REST_Request $request Request data.
32 32
 	 * @return array|\WP_Error
33 33
 	 */
34
-	public function get_items( $request ) {
34
+	public function get_items($request) {
35 35
 		$stock_query = new \WC_Admin_Reports_Stock_Stats_Query();
36 36
 		$report_data = $stock_query->get_data();
37 37
 		$out_data    = array(
38 38
 			'totals' => $report_data,
39 39
 		);
40
-		return rest_ensure_response( $out_data );
40
+		return rest_ensure_response($out_data);
41 41
 	}
42 42
 
43 43
 	/**
@@ -47,15 +47,15 @@  discard block
 block discarded – undo
47 47
 	 * @param  \WP_REST_Request $request Request object.
48 48
 	 * @return \WP_REST_Response
49 49
 	 */
50
-	public function prepare_item_for_response( $report, $request ) {
50
+	public function prepare_item_for_response($report, $request) {
51 51
 		$data = $report;
52 52
 
53
-		$context = ! empty( $request['context'] ) ? $request['context'] : 'view';
54
-		$data    = $this->add_additional_fields_to_object( $data, $request );
55
-		$data    = $this->filter_response_by_context( $data, $context );
53
+		$context = ! empty($request['context']) ? $request['context'] : 'view';
54
+		$data    = $this->add_additional_fields_to_object($data, $request);
55
+		$data    = $this->filter_response_by_context($data, $context);
56 56
 
57 57
 		// Wrap the data in a response object.
58
-		$response = rest_ensure_response( $data );
58
+		$response = rest_ensure_response($data);
59 59
 
60 60
 		/**
61 61
 		 * Filter a report returned from the API.
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 		 * @param WC_Product       $product   The original bject.
67 67
 		 * @param \WP_REST_Request  $request  Request used to generate the response.
68 68
 		 */
69
-		return apply_filters( 'woocommerce_rest_prepare_report_stock_stats', $response, $product, $request );
69
+		return apply_filters('woocommerce_rest_prepare_report_stock_stats', $response, $product, $request);
70 70
 	}
71 71
 
72 72
 	/**
@@ -77,26 +77,26 @@  discard block
 block discarded – undo
77 77
 	public function get_item_schema() {
78 78
 		$totals = array(
79 79
 			'products' => array(
80
-				'description' => __( 'Number of products.', 'woocommerce' ),
80
+				'description' => __('Number of products.', 'woocommerce'),
81 81
 				'type'        => 'integer',
82
-				'context'     => array( 'view', 'edit' ),
82
+				'context'     => array('view', 'edit'),
83 83
 				'readonly'    => true,
84 84
 			),
85 85
 			'lowstock' => array(
86
-				'description' => __( 'Number of low stock products.', 'woocommerce' ),
86
+				'description' => __('Number of low stock products.', 'woocommerce'),
87 87
 				'type'        => 'integer',
88
-				'context'     => array( 'view', 'edit' ),
88
+				'context'     => array('view', 'edit'),
89 89
 				'readonly'    => true,
90 90
 			),
91 91
 		);
92 92
 
93 93
 		$status_options = wc_get_product_stock_status_options();
94
-		foreach ( $status_options as $status => $label ) {
95
-			$totals[ $status ] = array(
94
+		foreach ($status_options as $status => $label) {
95
+			$totals[$status] = array(
96 96
 				/* translators: Stock status. Example: "Number of low stock products */
97
-				'description' => sprintf( __( 'Number of %s products.', 'woocommerce' ), $label ),
97
+				'description' => sprintf(__('Number of %s products.', 'woocommerce'), $label),
98 98
 				'type'        => 'integer',
99
-				'context'     => array( 'view', 'edit' ),
99
+				'context'     => array('view', 'edit'),
100 100
 				'readonly'    => true,
101 101
 			);
102 102
 		}
@@ -107,16 +107,16 @@  discard block
 block discarded – undo
107 107
 			'type'       => 'object',
108 108
 			'properties' => array(
109 109
 				'totals' => array(
110
-					'description' => __( 'Totals data.', 'woocommerce' ),
110
+					'description' => __('Totals data.', 'woocommerce'),
111 111
 					'type'        => 'object',
112
-					'context'     => array( 'view', 'edit' ),
112
+					'context'     => array('view', 'edit'),
113 113
 					'readonly'    => true,
114 114
 					'properties'  => $totals,
115 115
 				),
116 116
 			),
117 117
 		);
118 118
 
119
-		return $this->add_additional_fields_schema( $schema );
119
+		return $this->add_additional_fields_schema($schema);
120 120
 	}
121 121
 
122 122
 	/**
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 	 */
127 127
 	public function get_collection_params() {
128 128
 		$params            = array();
129
-		$params['context'] = $this->get_context_param( array( 'default' => 'view' ) );
129
+		$params['context'] = $this->get_context_param(array('default' => 'view'));
130 130
 		return $params;
131 131
 	}
132 132
 }
Please login to merge, or discard this patch.
src/RestApi/Version4/Controllers/Reports/ProductStats.php 1 patch
Spacing   +90 added lines, -90 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
 
10 10
 namespace WooCommerce\RestApi\Version4\Controllers\Reports;
11 11
 
12
-defined( 'ABSPATH' ) || exit;
12
+defined('ABSPATH') || exit;
13 13
 
14 14
 use \WooCommerce\RestApi\Version4\Controllers\Reports as Reports;
15 15
 
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 	 * Constructor.
39 39
 	 */
40 40
 	public function __construct() {
41
-		add_filter( 'woocommerce_reports_products_stats_select_query', array( $this, 'set_default_report_data' ) );
41
+		add_filter('woocommerce_reports_products_stats_select_query', array($this, 'set_default_report_data'));
42 42
 	}
43 43
 
44 44
 	/**
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 	 * @param \WP_REST_Request $request Request data.
48 48
 	 * @return array|\WP_Error
49 49
 	 */
50
-	public function get_items( $request ) {
50
+	public function get_items($request) {
51 51
 		$query_args = array(
52 52
 			'fields' => array(
53 53
 				'items_sold',
@@ -58,53 +58,53 @@  discard block
 block discarded – undo
58 58
 			),
59 59
 		);
60 60
 
61
-		$registered = array_keys( $this->get_collection_params() );
62
-		foreach ( $registered as $param_name ) {
63
-			if ( isset( $request[ $param_name ] ) ) {
64
-				if ( isset( $this->param_mapping[ $param_name ] ) ) {
65
-					$query_args[ $this->param_mapping[ $param_name ] ] = $request[ $param_name ];
61
+		$registered = array_keys($this->get_collection_params());
62
+		foreach ($registered as $param_name) {
63
+			if (isset($request[$param_name])) {
64
+				if (isset($this->param_mapping[$param_name])) {
65
+					$query_args[$this->param_mapping[$param_name]] = $request[$param_name];
66 66
 				} else {
67
-					$query_args[ $param_name ] = $request[ $param_name ];
67
+					$query_args[$param_name] = $request[$param_name];
68 68
 				}
69 69
 			}
70 70
 		}
71 71
 
72
-		$query = new \WC_Admin_Reports_Products_Stats_Query( $query_args );
72
+		$query = new \WC_Admin_Reports_Products_Stats_Query($query_args);
73 73
 		try {
74 74
 			$report_data = $query->get_data();
75
-		} catch ( \WC_Admin_Reports_Parameter_Exception $e ) {
76
-			return new \WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) );
75
+		} catch (\WC_Admin_Reports_Parameter_Exception $e) {
76
+			return new \WP_Error($e->getErrorCode(), $e->getMessage(), array('status' => $e->getCode()));
77 77
 		}
78 78
 
79 79
 		$out_data = array(
80
-			'totals'    => get_object_vars( $report_data->totals ),
80
+			'totals'    => get_object_vars($report_data->totals),
81 81
 			'intervals' => array(),
82 82
 		);
83 83
 
84
-		foreach ( $report_data->intervals as $interval_data ) {
85
-			$item                    = $this->prepare_item_for_response( $interval_data, $request );
86
-			$out_data['intervals'][] = $this->prepare_response_for_collection( $item );
84
+		foreach ($report_data->intervals as $interval_data) {
85
+			$item                    = $this->prepare_item_for_response($interval_data, $request);
86
+			$out_data['intervals'][] = $this->prepare_response_for_collection($item);
87 87
 		}
88 88
 
89
-		$response = rest_ensure_response( $out_data );
90
-		$response->header( 'X-WP-Total', (int) $report_data->total );
91
-		$response->header( 'X-WP-TotalPages', (int) $report_data->pages );
89
+		$response = rest_ensure_response($out_data);
90
+		$response->header('X-WP-Total', (int) $report_data->total);
91
+		$response->header('X-WP-TotalPages', (int) $report_data->pages);
92 92
 
93 93
 		$page      = $report_data->page_no;
94 94
 		$max_pages = $report_data->pages;
95
-		$base      = add_query_arg( $request->get_query_params(), rest_url( sprintf( '/%s/%s', $this->namespace, $this->rest_base ) ) );
96
-		if ( $page > 1 ) {
95
+		$base      = add_query_arg($request->get_query_params(), rest_url(sprintf('/%s/%s', $this->namespace, $this->rest_base)));
96
+		if ($page > 1) {
97 97
 			$prev_page = $page - 1;
98
-			if ( $prev_page > $max_pages ) {
98
+			if ($prev_page > $max_pages) {
99 99
 				$prev_page = $max_pages;
100 100
 			}
101
-			$prev_link = add_query_arg( 'page', $prev_page, $base );
102
-			$response->link_header( 'prev', $prev_link );
101
+			$prev_link = add_query_arg('page', $prev_page, $base);
102
+			$response->link_header('prev', $prev_link);
103 103
 		}
104
-		if ( $max_pages > $page ) {
104
+		if ($max_pages > $page) {
105 105
 			$next_page = $page + 1;
106
-			$next_link = add_query_arg( 'page', $next_page, $base );
107
-			$response->link_header( 'next', $next_link );
106
+			$next_link = add_query_arg('page', $next_page, $base);
107
+			$response->link_header('next', $next_link);
108 108
 		}
109 109
 
110 110
 		return $response;
@@ -117,15 +117,15 @@  discard block
 block discarded – undo
117 117
 	 * @param \WP_REST_Request $request Request object.
118 118
 	 * @return \WP_REST_Response
119 119
 	 */
120
-	public function prepare_item_for_response( $report, $request ) {
120
+	public function prepare_item_for_response($report, $request) {
121 121
 		$data = $report;
122 122
 
123
-		$context = ! empty( $request['context'] ) ? $request['context'] : 'view';
124
-		$data    = $this->add_additional_fields_to_object( $data, $request );
125
-		$data    = $this->filter_response_by_context( $data, $context );
123
+		$context = ! empty($request['context']) ? $request['context'] : 'view';
124
+		$data    = $this->add_additional_fields_to_object($data, $request);
125
+		$data    = $this->filter_response_by_context($data, $context);
126 126
 
127 127
 		// Wrap the data in a response object.
128
-		$response = rest_ensure_response( $data );
128
+		$response = rest_ensure_response($data);
129 129
 
130 130
 		/**
131 131
 		 * Filter a report returned from the API.
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 		 * @param object           $report   The original report object.
137 137
 		 * @param \WP_REST_Request  $request  Request used to generate the response.
138 138
 		 */
139
-		return apply_filters( 'woocommerce_rest_prepare_report_products_stats', $response, $report, $request );
139
+		return apply_filters('woocommerce_rest_prepare_report_products_stats', $response, $report, $request);
140 140
 	}
141 141
 
142 142
 	/**
@@ -147,53 +147,53 @@  discard block
 block discarded – undo
147 147
 	public function get_item_schema() {
148 148
 		$data_values = array(
149 149
 			'items_sold'   => array(
150
-				'description' => __( 'Number of items sold.', 'woocommerce' ),
150
+				'description' => __('Number of items sold.', 'woocommerce'),
151 151
 				'type'        => 'integer',
152
-				'context'     => array( 'view', 'edit' ),
152
+				'context'     => array('view', 'edit'),
153 153
 				'readonly'    => true,
154 154
 				'indicator'   => true,
155 155
 			),
156 156
 			'net_revenue'  => array(
157
-				'description' => __( 'Net revenue.', 'woocommerce' ),
157
+				'description' => __('Net revenue.', 'woocommerce'),
158 158
 				'type'        => 'number',
159
-				'context'     => array( 'view', 'edit' ),
159
+				'context'     => array('view', 'edit'),
160 160
 				'readonly'    => true,
161 161
 				'format'      => 'currency',
162 162
 			),
163 163
 			'orders_count' => array(
164
-				'description' => __( 'Number of orders.', 'woocommerce' ),
164
+				'description' => __('Number of orders.', 'woocommerce'),
165 165
 				'type'        => 'integer',
166
-				'context'     => array( 'view', 'edit' ),
166
+				'context'     => array('view', 'edit'),
167 167
 				'readonly'    => true,
168 168
 			),
169 169
 		);
170 170
 
171 171
 		$segments = array(
172 172
 			'segments' => array(
173
-				'description' => __( 'Reports data grouped by segment condition.', 'woocommerce' ),
173
+				'description' => __('Reports data grouped by segment condition.', 'woocommerce'),
174 174
 				'type'        => 'array',
175
-				'context'     => array( 'view', 'edit' ),
175
+				'context'     => array('view', 'edit'),
176 176
 				'readonly'    => true,
177 177
 				'items'       => array(
178 178
 					'type'       => 'object',
179 179
 					'properties' => array(
180 180
 						'segment_id'    => array(
181
-							'description' => __( 'Segment identificator.', 'woocommerce' ),
181
+							'description' => __('Segment identificator.', 'woocommerce'),
182 182
 							'type'        => 'integer',
183
-							'context'     => array( 'view', 'edit' ),
183
+							'context'     => array('view', 'edit'),
184 184
 							'readonly'    => true,
185 185
 						),
186 186
 						'segment_label' => array(
187
-							'description' => __( 'Human readable segment label, either product or variation name.', 'woocommerce' ),
187
+							'description' => __('Human readable segment label, either product or variation name.', 'woocommerce'),
188 188
 							'type'        => 'string',
189
-							'context'     => array( 'view', 'edit' ),
189
+							'context'     => array('view', 'edit'),
190 190
 							'readonly'    => true,
191
-							'enum'        => array( 'day', 'week', 'month', 'year' ),
191
+							'enum'        => array('day', 'week', 'month', 'year'),
192 192
 						),
193 193
 						'subtotals'     => array(
194
-							'description' => __( 'Interval subtotals.', 'woocommerce' ),
194
+							'description' => __('Interval subtotals.', 'woocommerce'),
195 195
 							'type'        => 'object',
196
-							'context'     => array( 'view', 'edit' ),
196
+							'context'     => array('view', 'edit'),
197 197
 							'readonly'    => true,
198 198
 							'properties'  => $data_values,
199 199
 						),
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
 			),
203 203
 		);
204 204
 
205
-		$totals = array_merge( $data_values, $segments );
205
+		$totals = array_merge($data_values, $segments);
206 206
 
207 207
 		$schema = array(
208 208
 			'$schema'    => 'http://json-schema.org/draft-04/schema#',
@@ -210,55 +210,55 @@  discard block
 block discarded – undo
210 210
 			'type'       => 'object',
211 211
 			'properties' => array(
212 212
 				'totals'    => array(
213
-					'description' => __( 'Totals data.', 'woocommerce' ),
213
+					'description' => __('Totals data.', 'woocommerce'),
214 214
 					'type'        => 'object',
215
-					'context'     => array( 'view', 'edit' ),
215
+					'context'     => array('view', 'edit'),
216 216
 					'readonly'    => true,
217 217
 					'properties'  => $totals,
218 218
 				),
219 219
 				'intervals' => array(
220
-					'description' => __( 'Reports data grouped by intervals.', 'woocommerce' ),
220
+					'description' => __('Reports data grouped by intervals.', 'woocommerce'),
221 221
 					'type'        => 'array',
222
-					'context'     => array( 'view', 'edit' ),
222
+					'context'     => array('view', 'edit'),
223 223
 					'readonly'    => true,
224 224
 					'items'       => array(
225 225
 						'type'       => 'object',
226 226
 						'properties' => array(
227 227
 							'interval'       => array(
228
-								'description' => __( 'Type of interval.', 'woocommerce' ),
228
+								'description' => __('Type of interval.', 'woocommerce'),
229 229
 								'type'        => 'string',
230
-								'context'     => array( 'view', 'edit' ),
230
+								'context'     => array('view', 'edit'),
231 231
 								'readonly'    => true,
232
-								'enum'        => array( 'day', 'week', 'month', 'year' ),
232
+								'enum'        => array('day', 'week', 'month', 'year'),
233 233
 							),
234 234
 							'date_start'     => array(
235
-								'description' => __( "The date the report start, in the site's timezone.", 'woocommerce' ),
235
+								'description' => __("The date the report start, in the site's timezone.", 'woocommerce'),
236 236
 								'type'        => 'date-time',
237
-								'context'     => array( 'view', 'edit' ),
237
+								'context'     => array('view', 'edit'),
238 238
 								'readonly'    => true,
239 239
 							),
240 240
 							'date_start_gmt' => array(
241
-								'description' => __( 'The date the report start, as GMT.', 'woocommerce' ),
241
+								'description' => __('The date the report start, as GMT.', 'woocommerce'),
242 242
 								'type'        => 'date-time',
243
-								'context'     => array( 'view', 'edit' ),
243
+								'context'     => array('view', 'edit'),
244 244
 								'readonly'    => true,
245 245
 							),
246 246
 							'date_end'       => array(
247
-								'description' => __( "The date the report end, in the site's timezone.", 'woocommerce' ),
247
+								'description' => __("The date the report end, in the site's timezone.", 'woocommerce'),
248 248
 								'type'        => 'date-time',
249
-								'context'     => array( 'view', 'edit' ),
249
+								'context'     => array('view', 'edit'),
250 250
 								'readonly'    => true,
251 251
 							),
252 252
 							'date_end_gmt'   => array(
253
-								'description' => __( 'The date the report end, as GMT.', 'woocommerce' ),
253
+								'description' => __('The date the report end, as GMT.', 'woocommerce'),
254 254
 								'type'        => 'date-time',
255
-								'context'     => array( 'view', 'edit' ),
255
+								'context'     => array('view', 'edit'),
256 256
 								'readonly'    => true,
257 257
 							),
258 258
 							'subtotals'      => array(
259
-								'description' => __( 'Interval subtotals.', 'woocommerce' ),
259
+								'description' => __('Interval subtotals.', 'woocommerce'),
260 260
 								'type'        => 'object',
261
-								'context'     => array( 'view', 'edit' ),
261
+								'context'     => array('view', 'edit'),
262 262
 								'readonly'    => true,
263 263
 								'properties'  => $totals,
264 264
 							),
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
 			),
269 269
 		);
270 270
 
271
-		return $this->add_additional_fields_schema( $schema );
271
+		return $this->add_additional_fields_schema($schema);
272 272
 	}
273 273
 
274 274
 	/**
@@ -277,8 +277,8 @@  discard block
 block discarded – undo
277 277
 	 * @param Mixed $results Report data.
278 278
 	 * @return object
279 279
 	 */
280
-	public function set_default_report_data( $results ) {
281
-		if ( empty( $results ) ) {
280
+	public function set_default_report_data($results) {
281
+		if (empty($results)) {
282 282
 			$results                       = new \stdClass();
283 283
 			$results->total                = 0;
284 284
 			$results->totals               = new \stdClass();
@@ -299,17 +299,17 @@  discard block
 block discarded – undo
299 299
 	 */
300 300
 	public function get_collection_params() {
301 301
 		$params               = array();
302
-		$params['context']    = $this->get_context_param( array( 'default' => 'view' ) );
302
+		$params['context']    = $this->get_context_param(array('default' => 'view'));
303 303
 		$params['page']       = array(
304
-			'description'       => __( 'Current page of the collection.', 'woocommerce' ),
304
+			'description'       => __('Current page of the collection.', 'woocommerce'),
305 305
 			'type'              => 'integer',
306 306
 			'default'           => 1,
307 307
 			'sanitize_callback' => 'absint',
308 308
 			'validate_callback' => 'rest_validate_request_arg',
309 309
 			'minimum'           => 1,
310 310
 		);
311
-		$params['per_page']   = array(
312
-			'description'       => __( 'Maximum number of items to be returned in result set.', 'woocommerce' ),
311
+		$params['per_page'] = array(
312
+			'description'       => __('Maximum number of items to be returned in result set.', 'woocommerce'),
313 313
 			'type'              => 'integer',
314 314
 			'default'           => 10,
315 315
 			'minimum'           => 1,
@@ -317,27 +317,27 @@  discard block
 block discarded – undo
317 317
 			'sanitize_callback' => 'absint',
318 318
 			'validate_callback' => 'rest_validate_request_arg',
319 319
 		);
320
-		$params['after']      = array(
321
-			'description'       => __( 'Limit response to resources published after a given ISO8601 compliant date.', 'woocommerce' ),
320
+		$params['after'] = array(
321
+			'description'       => __('Limit response to resources published after a given ISO8601 compliant date.', 'woocommerce'),
322 322
 			'type'              => 'string',
323 323
 			'format'            => 'date-time',
324 324
 			'validate_callback' => 'rest_validate_request_arg',
325 325
 		);
326
-		$params['before']     = array(
327
-			'description'       => __( 'Limit response to resources published before a given ISO8601 compliant date.', 'woocommerce' ),
326
+		$params['before'] = array(
327
+			'description'       => __('Limit response to resources published before a given ISO8601 compliant date.', 'woocommerce'),
328 328
 			'type'              => 'string',
329 329
 			'format'            => 'date-time',
330 330
 			'validate_callback' => 'rest_validate_request_arg',
331 331
 		);
332
-		$params['order']      = array(
333
-			'description'       => __( 'Order sort attribute ascending or descending.', 'woocommerce' ),
332
+		$params['order'] = array(
333
+			'description'       => __('Order sort attribute ascending or descending.', 'woocommerce'),
334 334
 			'type'              => 'string',
335 335
 			'default'           => 'desc',
336
-			'enum'              => array( 'asc', 'desc' ),
336
+			'enum'              => array('asc', 'desc'),
337 337
 			'validate_callback' => 'rest_validate_request_arg',
338 338
 		);
339
-		$params['orderby']    = array(
340
-			'description'       => __( 'Sort collection by object attribute.', 'woocommerce' ),
339
+		$params['orderby'] = array(
340
+			'description'       => __('Sort collection by object attribute.', 'woocommerce'),
341 341
 			'type'              => 'string',
342 342
 			'default'           => 'date',
343 343
 			'enum'              => array(
@@ -353,8 +353,8 @@  discard block
 block discarded – undo
353 353
 			),
354 354
 			'validate_callback' => 'rest_validate_request_arg',
355 355
 		);
356
-		$params['interval']   = array(
357
-			'description'       => __( 'Time interval to use for buckets in the returned data.', 'woocommerce' ),
356
+		$params['interval'] = array(
357
+			'description'       => __('Time interval to use for buckets in the returned data.', 'woocommerce'),
358 358
 			'type'              => 'string',
359 359
 			'default'           => 'week',
360 360
 			'enum'              => array(
@@ -368,7 +368,7 @@  discard block
 block discarded – undo
368 368
 			'validate_callback' => 'rest_validate_request_arg',
369 369
 		);
370 370
 		$params['categories'] = array(
371
-			'description'       => __( 'Limit result to items from the specified categories.', 'woocommerce' ),
371
+			'description'       => __('Limit result to items from the specified categories.', 'woocommerce'),
372 372
 			'type'              => 'array',
373 373
 			'sanitize_callback' => 'wp_parse_id_list',
374 374
 			'validate_callback' => 'rest_validate_request_arg',
@@ -376,8 +376,8 @@  discard block
 block discarded – undo
376 376
 				'type' => 'integer',
377 377
 			),
378 378
 		);
379
-		$params['products']   = array(
380
-			'description'       => __( 'Limit result to items with specified product ids.', 'woocommerce' ),
379
+		$params['products'] = array(
380
+			'description'       => __('Limit result to items with specified product ids.', 'woocommerce'),
381 381
 			'type'              => 'array',
382 382
 			'sanitize_callback' => 'wp_parse_id_list',
383 383
 			'validate_callback' => 'rest_validate_request_arg',
@@ -386,7 +386,7 @@  discard block
 block discarded – undo
386 386
 			),
387 387
 		);
388 388
 		$params['variations'] = array(
389
-			'description'       => __( 'Limit result to items with specified variation ids.', 'woocommerce' ),
389
+			'description'       => __('Limit result to items with specified variation ids.', 'woocommerce'),
390 390
 			'type'              => 'array',
391 391
 			'sanitize_callback' => 'wp_parse_id_list',
392 392
 			'validate_callback' => 'rest_validate_request_arg',
@@ -394,8 +394,8 @@  discard block
 block discarded – undo
394 394
 				'type' => 'integer',
395 395
 			),
396 396
 		);
397
-		$params['segmentby']  = array(
398
-			'description'       => __( 'Segment the response by additional constraint.', 'woocommerce' ),
397
+		$params['segmentby'] = array(
398
+			'description'       => __('Segment the response by additional constraint.', 'woocommerce'),
399 399
 			'type'              => 'string',
400 400
 			'enum'              => array(
401 401
 				'product',
Please login to merge, or discard this patch.
src/RestApi/Version4/Controllers/Reports/Import.php 1 patch
Spacing   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
 
10 10
 namespace WooCommerce\RestApi\Version4\Controllers\Reports;
11 11
 
12
-defined( 'ABSPATH' ) || exit;
12
+defined('ABSPATH') || exit;
13 13
 
14 14
 use \WooCommerce\RestApi\Version4\Controllers\Reports as Reports;
15 15
 
@@ -35,11 +35,11 @@  discard block
 block discarded – undo
35 35
 			array(
36 36
 				array(
37 37
 					'methods'             => \WP_REST_Server::EDITABLE,
38
-					'callback'            => array( $this, 'import_items' ),
39
-					'permission_callback' => array( $this, 'import_permissions_check' ),
38
+					'callback'            => array($this, 'import_items'),
39
+					'permission_callback' => array($this, 'import_permissions_check'),
40 40
 					'args'                => $this->get_import_collection_params(),
41 41
 				),
42
-				'schema' => array( $this, 'get_import_public_schema' ),
42
+				'schema' => array($this, 'get_import_public_schema'),
43 43
 			)
44 44
 		);
45 45
 		register_rest_route(
@@ -48,10 +48,10 @@  discard block
 block discarded – undo
48 48
 			array(
49 49
 				array(
50 50
 					'methods'             => \WP_REST_Server::EDITABLE,
51
-					'callback'            => array( $this, 'cancel_import' ),
52
-					'permission_callback' => array( $this, 'import_permissions_check' ),
51
+					'callback'            => array($this, 'cancel_import'),
52
+					'permission_callback' => array($this, 'import_permissions_check'),
53 53
 				),
54
-				'schema' => array( $this, 'get_import_public_schema' ),
54
+				'schema' => array($this, 'get_import_public_schema'),
55 55
 			)
56 56
 		);
57 57
 		register_rest_route(
@@ -60,10 +60,10 @@  discard block
 block discarded – undo
60 60
 			array(
61 61
 				array(
62 62
 					'methods'             => \WP_REST_Server::EDITABLE,
63
-					'callback'            => array( $this, 'delete_imported_items' ),
64
-					'permission_callback' => array( $this, 'import_permissions_check' ),
63
+					'callback'            => array($this, 'delete_imported_items'),
64
+					'permission_callback' => array($this, 'import_permissions_check'),
65 65
 				),
66
-				'schema' => array( $this, 'get_import_public_schema' ),
66
+				'schema' => array($this, 'get_import_public_schema'),
67 67
 			)
68 68
 		);
69 69
 		register_rest_route(
@@ -72,10 +72,10 @@  discard block
 block discarded – undo
72 72
 			array(
73 73
 				array(
74 74
 					'methods'             => \WP_REST_Server::READABLE,
75
-					'callback'            => array( $this, 'get_import_status' ),
76
-					'permission_callback' => array( $this, 'import_permissions_check' ),
75
+					'callback'            => array($this, 'get_import_status'),
76
+					'permission_callback' => array($this, 'import_permissions_check'),
77 77
 				),
78
-				'schema' => array( $this, 'get_import_public_schema' ),
78
+				'schema' => array($this, 'get_import_public_schema'),
79 79
 			)
80 80
 		);
81 81
 		register_rest_route(
@@ -84,11 +84,11 @@  discard block
 block discarded – undo
84 84
 			array(
85 85
 				array(
86 86
 					'methods'             => \WP_REST_Server::READABLE,
87
-					'callback'            => array( $this, 'get_import_totals' ),
88
-					'permission_callback' => array( $this, 'import_permissions_check' ),
87
+					'callback'            => array($this, 'get_import_totals'),
88
+					'permission_callback' => array($this, 'import_permissions_check'),
89 89
 					'args'                => $this->get_import_collection_params(),
90 90
 				),
91
-				'schema' => array( $this, 'get_import_public_schema' ),
91
+				'schema' => array($this, 'get_import_public_schema'),
92 92
 			)
93 93
 		);
94 94
 	}
@@ -99,9 +99,9 @@  discard block
 block discarded – undo
99 99
 	 * @param \WP_REST_Request $request Full data about the request.
100 100
 	 * @return \WP_Error|bool
101 101
 	 */
102
-	public function import_permissions_check( $request ) {
103
-		if ( ! wc_rest_check_manager_permissions( 'settings', 'edit' ) ) {
104
-			return new \WP_Error( 'woocommerce_rest_cannot_edit', __( 'Sorry, you cannot edit this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
102
+	public function import_permissions_check($request) {
103
+		if ( ! wc_rest_check_manager_permissions('settings', 'edit')) {
104
+			return new \WP_Error('woocommerce_rest_cannot_edit', __('Sorry, you cannot edit this resource.', 'woocommerce'), array('status' => rest_authorization_required_code()));
105 105
 		}
106 106
 		return true;
107 107
 	}
@@ -112,11 +112,11 @@  discard block
 block discarded – undo
112 112
 	 * @param  \WP_REST_Request $request Request data.
113 113
 	 * @return \WP_Error\WP_REST_Response
114 114
 	 */
115
-	public function import_items( $request ) {
116
-		$query_args = $this->prepare_objects_query( $request );
117
-		$import     = \WC_Admin_Reports_Sync::regenerate_report_data( $query_args['days'], $query_args['skip_existing'] );
115
+	public function import_items($request) {
116
+		$query_args = $this->prepare_objects_query($request);
117
+		$import     = \WC_Admin_Reports_Sync::regenerate_report_data($query_args['days'], $query_args['skip_existing']);
118 118
 
119
-		if ( is_wp_error( $import ) ) {
119
+		if (is_wp_error($import)) {
120 120
 			$result = array(
121 121
 				'status'  => 'error',
122 122
 				'message' => $import->get_error_message(),
@@ -128,10 +128,10 @@  discard block
 block discarded – undo
128 128
 			);
129 129
 		}
130 130
 
131
-		$response = $this->prepare_item_for_response( $result, $request );
132
-		$data     = $this->prepare_response_for_collection( $response );
131
+		$response = $this->prepare_item_for_response($result, $request);
132
+		$data     = $this->prepare_response_for_collection($response);
133 133
 
134
-		return rest_ensure_response( $data );
134
+		return rest_ensure_response($data);
135 135
 	}
136 136
 
137 137
 	/**
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 	 * @param \WP_REST_Request $request Request data.
141 141
 	 * @return array
142 142
 	 */
143
-	protected function prepare_objects_query( $request ) {
143
+	protected function prepare_objects_query($request) {
144 144
 		$args                  = array();
145 145
 		$args['skip_existing'] = $request['skip_existing'];
146 146
 		$args['days']          = $request['days'];
@@ -155,10 +155,10 @@  discard block
 block discarded – undo
155 155
 	 * @param \WP_REST_Request $request Request object.
156 156
 	 * @return \WP_REST_Response $response Response data.
157 157
 	 */
158
-	public function prepare_item_for_response( $item, $request ) {
159
-		$data     = $this->add_additional_fields_to_object( $item, $request );
160
-		$data     = $this->filter_response_by_context( $data, 'view' );
161
-		$response = rest_ensure_response( $data );
158
+	public function prepare_item_for_response($item, $request) {
159
+		$data     = $this->add_additional_fields_to_object($item, $request);
160
+		$data     = $this->filter_response_by_context($data, 'view');
161
+		$response = rest_ensure_response($data);
162 162
 
163 163
 		/**
164 164
 		 * Filter the list returned from the API.
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
 		 * @param array            $item     The original item.
168 168
 		 * @param \WP_REST_Request  $request  Request used to generate the response.
169 169
 		 */
170
-		return apply_filters( 'woocommerce_rest_prepare_reports_import', $response, $item, $request );
170
+		return apply_filters('woocommerce_rest_prepare_reports_import', $response, $item, $request);
171 171
 	}
172 172
 
173 173
 	/**
@@ -178,14 +178,14 @@  discard block
 block discarded – undo
178 178
 	public function get_import_collection_params() {
179 179
 		$params                  = array();
180 180
 		$params['days']          = array(
181
-			'description'       => __( 'Number of days to import.', 'woocommerce' ),
181
+			'description'       => __('Number of days to import.', 'woocommerce'),
182 182
 			'type'              => 'integer',
183 183
 			'sanitize_callback' => 'absint',
184 184
 			'validate_callback' => 'rest_validate_request_arg',
185 185
 			'minimum'           => 1,
186 186
 		);
187 187
 		$params['skip_existing'] = array(
188
-			'description'       => __( 'Skip importing existing order data.', 'woocommerce' ),
188
+			'description'       => __('Skip importing existing order data.', 'woocommerce'),
189 189
 			'type'              => 'boolean',
190 190
 			'default'           => false,
191 191
 			'sanitize_callback' => 'wc_string_to_bool',
@@ -206,21 +206,21 @@  discard block
 block discarded – undo
206 206
 			'type'       => 'object',
207 207
 			'properties' => array(
208 208
 				'status'  => array(
209
-					'description' => __( 'Regeneration status.', 'woocommerce' ),
209
+					'description' => __('Regeneration status.', 'woocommerce'),
210 210
 					'type'        => 'string',
211
-					'context'     => array( 'view', 'edit' ),
211
+					'context'     => array('view', 'edit'),
212 212
 					'readonly'    => true,
213 213
 				),
214 214
 				'message' => array(
215
-					'description' => __( 'Regenerate data message.', 'woocommerce' ),
215
+					'description' => __('Regenerate data message.', 'woocommerce'),
216 216
 					'type'        => 'string',
217
-					'context'     => array( 'view', 'edit' ),
217
+					'context'     => array('view', 'edit'),
218 218
 					'readonly'    => true,
219 219
 				),
220 220
 			),
221 221
 		);
222 222
 
223
-		return $this->add_additional_fields_schema( $schema );
223
+		return $this->add_additional_fields_schema($schema);
224 224
 	}
225 225
 
226 226
 	/**
@@ -229,18 +229,18 @@  discard block
 block discarded – undo
229 229
 	 * @param  \WP_REST_Request $request Request data.
230 230
 	 * @return \WP_Error\WP_REST_Response
231 231
 	 */
232
-	public function cancel_import( $request ) {
232
+	public function cancel_import($request) {
233 233
 		\WC_Admin_Reports_Sync::clear_queued_actions();
234 234
 
235 235
 		$result = array(
236 236
 			'status'  => 'success',
237
-			'message' => __( 'All pending and in-progress import actions have been cancelled.', 'woocommerce' ),
237
+			'message' => __('All pending and in-progress import actions have been cancelled.', 'woocommerce'),
238 238
 		);
239 239
 
240
-		$response = $this->prepare_item_for_response( $result, $request );
241
-		$data     = $this->prepare_response_for_collection( $response );
240
+		$response = $this->prepare_item_for_response($result, $request);
241
+		$data     = $this->prepare_response_for_collection($response);
242 242
 
243
-		return rest_ensure_response( $data );
243
+		return rest_ensure_response($data);
244 244
 	}
245 245
 
246 246
 	/**
@@ -249,10 +249,10 @@  discard block
 block discarded – undo
249 249
 	 * @param  \WP_REST_Request $request Request data.
250 250
 	 * @return \WP_Error\WP_REST_Response
251 251
 	 */
252
-	public function delete_imported_items( $request ) {
252
+	public function delete_imported_items($request) {
253 253
 		$delete = \WC_Admin_Reports_Sync::delete_report_data();
254 254
 
255
-		if ( is_wp_error( $delete ) ) {
255
+		if (is_wp_error($delete)) {
256 256
 			$result = array(
257 257
 				'status'  => 'error',
258 258
 				'message' => $delete->get_error_message(),
@@ -264,10 +264,10 @@  discard block
 block discarded – undo
264 264
 			);
265 265
 		}
266 266
 
267
-		$response = $this->prepare_item_for_response( $result, $request );
268
-		$data     = $this->prepare_response_for_collection( $response );
267
+		$response = $this->prepare_item_for_response($result, $request);
268
+		$data     = $this->prepare_response_for_collection($response);
269 269
 
270
-		return rest_ensure_response( $data );
270
+		return rest_ensure_response($data);
271 271
 	}
272 272
 
273 273
 	/**
@@ -276,20 +276,20 @@  discard block
 block discarded – undo
276 276
 	 * @param  \WP_REST_Request $request Request data.
277 277
 	 * @return \WP_Error\WP_REST_Response
278 278
 	 */
279
-	public function get_import_status( $request ) {
279
+	public function get_import_status($request) {
280 280
 		$result = array(
281 281
 			'is_importing'    => \WC_Admin_Reports_Sync::is_importing(),
282
-			'customers_total' => get_option( 'wc_admin_import_customers_total', 0 ),
283
-			'customers_count' => get_option( 'wc_admin_import_customers_count', 0 ),
284
-			'orders_total'    => get_option( 'wc_admin_import_orders_total', 0 ),
285
-			'orders_count'    => get_option( 'wc_admin_import_orders_count', 0 ),
286
-			'imported_from'   => get_option( 'wc_admin_imported_from_date', false ),
282
+			'customers_total' => get_option('wc_admin_import_customers_total', 0),
283
+			'customers_count' => get_option('wc_admin_import_customers_count', 0),
284
+			'orders_total'    => get_option('wc_admin_import_orders_total', 0),
285
+			'orders_count'    => get_option('wc_admin_import_orders_count', 0),
286
+			'imported_from'   => get_option('wc_admin_imported_from_date', false),
287 287
 		);
288 288
 
289
-		$response = $this->prepare_item_for_response( $result, $request );
290
-		$data     = $this->prepare_response_for_collection( $response );
289
+		$response = $this->prepare_item_for_response($result, $request);
290
+		$data     = $this->prepare_response_for_collection($response);
291 291
 
292
-		return rest_ensure_response( $data );
292
+		return rest_ensure_response($data);
293 293
 	}
294 294
 
295 295
 	/**
@@ -298,13 +298,13 @@  discard block
 block discarded – undo
298 298
 	 * @param  \WP_REST_Request $request Request data.
299 299
 	 * @return \WP_Error\WP_REST_Response
300 300
 	 */
301
-	public function get_import_totals( $request ) {
302
-		$query_args = $this->prepare_objects_query( $request );
303
-		$totals     = \WC_Admin_Reports_Sync::get_import_totals( $query_args['days'], $query_args['skip_existing'] );
301
+	public function get_import_totals($request) {
302
+		$query_args = $this->prepare_objects_query($request);
303
+		$totals     = \WC_Admin_Reports_Sync::get_import_totals($query_args['days'], $query_args['skip_existing']);
304 304
 
305
-		$response = $this->prepare_item_for_response( $totals, $request );
306
-		$data     = $this->prepare_response_for_collection( $response );
305
+		$response = $this->prepare_item_for_response($totals, $request);
306
+		$data     = $this->prepare_response_for_collection($response);
307 307
 
308
-		return rest_ensure_response( $data );
308
+		return rest_ensure_response($data);
309 309
 	}
310 310
 }
Please login to merge, or discard this patch.
src/RestApi/Version4/Controllers/Reports/Taxes.php 1 patch
Spacing   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
 
10 10
 namespace WooCommerce\RestApi\Version4\Controllers\Reports;
11 11
 
12
-defined( 'ABSPATH' ) || exit;
12
+defined('ABSPATH') || exit;
13 13
 
14 14
 use \WooCommerce\RestApi\Version4\Controllers\Reports as Reports;
15 15
 
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 	 * @param array $request Request array.
32 32
 	 * @return array
33 33
 	 */
34
-	protected function prepare_reports_query( $request ) {
34
+	protected function prepare_reports_query($request) {
35 35
 		$args             = array();
36 36
 		$args['before']   = $request['before'];
37 37
 		$args['after']    = $request['after'];
@@ -50,37 +50,37 @@  discard block
 block discarded – undo
50 50
 	 * @param \WP_REST_Request $request Request data.
51 51
 	 * @return array|\WP_Error
52 52
 	 */
53
-	public function get_items( $request ) {
54
-		$query_args  = $this->prepare_reports_query( $request );
55
-		$taxes_query = new \WC_Admin_Reports_Taxes_Query( $query_args );
53
+	public function get_items($request) {
54
+		$query_args  = $this->prepare_reports_query($request);
55
+		$taxes_query = new \WC_Admin_Reports_Taxes_Query($query_args);
56 56
 		$report_data = $taxes_query->get_data();
57 57
 
58 58
 		$data = array();
59 59
 
60
-		foreach ( $report_data->data as $tax_data ) {
61
-			$item   = $this->prepare_item_for_response( (object) $tax_data, $request );
62
-			$data[] = $this->prepare_response_for_collection( $item );
60
+		foreach ($report_data->data as $tax_data) {
61
+			$item   = $this->prepare_item_for_response((object) $tax_data, $request);
62
+			$data[] = $this->prepare_response_for_collection($item);
63 63
 		}
64 64
 
65
-		$response = rest_ensure_response( $data );
66
-		$response->header( 'X-WP-Total', (int) $report_data->total );
67
-		$response->header( 'X-WP-TotalPages', (int) $report_data->pages );
65
+		$response = rest_ensure_response($data);
66
+		$response->header('X-WP-Total', (int) $report_data->total);
67
+		$response->header('X-WP-TotalPages', (int) $report_data->pages);
68 68
 
69 69
 		$page      = $report_data->page_no;
70 70
 		$max_pages = $report_data->pages;
71
-		$base      = add_query_arg( $request->get_query_params(), rest_url( sprintf( '/%s/%s', $this->namespace, $this->rest_base ) ) );
72
-		if ( $page > 1 ) {
71
+		$base      = add_query_arg($request->get_query_params(), rest_url(sprintf('/%s/%s', $this->namespace, $this->rest_base)));
72
+		if ($page > 1) {
73 73
 			$prev_page = $page - 1;
74
-			if ( $prev_page > $max_pages ) {
74
+			if ($prev_page > $max_pages) {
75 75
 				$prev_page = $max_pages;
76 76
 			}
77
-			$prev_link = add_query_arg( 'page', $prev_page, $base );
78
-			$response->link_header( 'prev', $prev_link );
77
+			$prev_link = add_query_arg('page', $prev_page, $base);
78
+			$response->link_header('prev', $prev_link);
79 79
 		}
80
-		if ( $max_pages > $page ) {
80
+		if ($max_pages > $page) {
81 81
 			$next_page = $page + 1;
82
-			$next_link = add_query_arg( 'page', $next_page, $base );
83
-			$response->link_header( 'next', $next_link );
82
+			$next_link = add_query_arg('page', $next_page, $base);
83
+			$response->link_header('next', $next_link);
84 84
 		}
85 85
 
86 86
 		return $response;
@@ -93,14 +93,14 @@  discard block
 block discarded – undo
93 93
 	 * @param \WP_REST_Request $request Request object.
94 94
 	 * @return \WP_REST_Response
95 95
 	 */
96
-	public function prepare_item_for_response( $report, $request ) {
97
-		$context = ! empty( $request['context'] ) ? $request['context'] : 'view';
98
-		$report  = $this->add_additional_fields_to_object( $report, $request );
99
-		$report  = $this->filter_response_by_context( $report, $context );
96
+	public function prepare_item_for_response($report, $request) {
97
+		$context = ! empty($request['context']) ? $request['context'] : 'view';
98
+		$report  = $this->add_additional_fields_to_object($report, $request);
99
+		$report  = $this->filter_response_by_context($report, $context);
100 100
 
101 101
 		// Wrap the data in a response object.
102
-		$response = rest_ensure_response( $report );
103
-		$response->add_links( $this->prepare_links( $report ) );
102
+		$response = rest_ensure_response($report);
103
+		$response->add_links($this->prepare_links($report));
104 104
 
105 105
 		/**
106 106
 		 * Filter a report returned from the API.
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 		 * @param object           $report   The original report object.
112 112
 		 * @param \WP_REST_Request  $request  Request used to generate the response.
113 113
 		 */
114
-		return apply_filters( 'woocommerce_rest_prepare_report_taxes', $response, $report, $request );
114
+		return apply_filters('woocommerce_rest_prepare_report_taxes', $response, $report, $request);
115 115
 	}
116 116
 
117 117
 	/**
@@ -120,10 +120,10 @@  discard block
 block discarded – undo
120 120
 	 * @param WC_Reports_Query $object Object data.
121 121
 	 * @return array
122 122
 	 */
123
-	protected function prepare_links( $object ) {
123
+	protected function prepare_links($object) {
124 124
 		$links = array(
125 125
 			'tax' => array(
126
-				'href' => rest_url( sprintf( '/%s/taxes/%d', $this->namespace, $object->tax_rate_id ) ),
126
+				'href' => rest_url(sprintf('/%s/taxes/%d', $this->namespace, $object->tax_rate_id)),
127 127
 			),
128 128
 		);
129 129
 
@@ -142,69 +142,69 @@  discard block
 block discarded – undo
142 142
 			'type'       => 'object',
143 143
 			'properties' => array(
144 144
 				'tax_rate_id'  => array(
145
-					'description' => __( 'Tax rate ID.', 'woocommerce' ),
145
+					'description' => __('Tax rate ID.', 'woocommerce'),
146 146
 					'type'        => 'integer',
147
-					'context'     => array( 'view', 'edit' ),
147
+					'context'     => array('view', 'edit'),
148 148
 					'readonly'    => true,
149 149
 				),
150 150
 				'name'         => array(
151
-					'description' => __( 'Tax rate name.', 'woocommerce' ),
151
+					'description' => __('Tax rate name.', 'woocommerce'),
152 152
 					'type'        => 'string',
153
-					'context'     => array( 'view', 'edit' ),
153
+					'context'     => array('view', 'edit'),
154 154
 					'readonly'    => true,
155 155
 				),
156 156
 				'tax_rate'     => array(
157
-					'description' => __( 'Tax rate.', 'woocommerce' ),
157
+					'description' => __('Tax rate.', 'woocommerce'),
158 158
 					'type'        => 'number',
159
-					'context'     => array( 'view', 'edit' ),
159
+					'context'     => array('view', 'edit'),
160 160
 					'readonly'    => true,
161 161
 				),
162 162
 				'country'      => array(
163
-					'description' => __( 'Country.', 'woocommerce' ),
163
+					'description' => __('Country.', 'woocommerce'),
164 164
 					'type'        => 'string',
165
-					'context'     => array( 'view', 'edit' ),
165
+					'context'     => array('view', 'edit'),
166 166
 					'readonly'    => true,
167 167
 				),
168 168
 				'state'        => array(
169
-					'description' => __( 'State.', 'woocommerce' ),
169
+					'description' => __('State.', 'woocommerce'),
170 170
 					'type'        => 'string',
171
-					'context'     => array( 'view', 'edit' ),
171
+					'context'     => array('view', 'edit'),
172 172
 					'readonly'    => true,
173 173
 				),
174 174
 				'priority'     => array(
175
-					'description' => __( 'Priority.', 'woocommerce' ),
175
+					'description' => __('Priority.', 'woocommerce'),
176 176
 					'type'        => 'integer',
177
-					'context'     => array( 'view', 'edit' ),
177
+					'context'     => array('view', 'edit'),
178 178
 					'readonly'    => true,
179 179
 				),
180 180
 				'total_tax'    => array(
181
-					'description' => __( 'Total tax.', 'woocommerce' ),
181
+					'description' => __('Total tax.', 'woocommerce'),
182 182
 					'type'        => 'number',
183
-					'context'     => array( 'view', 'edit' ),
183
+					'context'     => array('view', 'edit'),
184 184
 					'readonly'    => true,
185 185
 				),
186 186
 				'order_tax'    => array(
187
-					'description' => __( 'Order tax.', 'woocommerce' ),
187
+					'description' => __('Order tax.', 'woocommerce'),
188 188
 					'type'        => 'number',
189
-					'context'     => array( 'view', 'edit' ),
189
+					'context'     => array('view', 'edit'),
190 190
 					'readonly'    => true,
191 191
 				),
192 192
 				'shipping_tax' => array(
193
-					'description' => __( 'Shipping tax.', 'woocommerce' ),
193
+					'description' => __('Shipping tax.', 'woocommerce'),
194 194
 					'type'        => 'number',
195
-					'context'     => array( 'view', 'edit' ),
195
+					'context'     => array('view', 'edit'),
196 196
 					'readonly'    => true,
197 197
 				),
198 198
 				'orders_count' => array(
199
-					'description' => __( 'Amount of orders.', 'woocommerce' ),
199
+					'description' => __('Amount of orders.', 'woocommerce'),
200 200
 					'type'        => 'integer',
201
-					'context'     => array( 'view', 'edit' ),
201
+					'context'     => array('view', 'edit'),
202 202
 					'readonly'    => true,
203 203
 				),
204 204
 			),
205 205
 		);
206 206
 
207
-		return $this->add_additional_fields_schema( $schema );
207
+		return $this->add_additional_fields_schema($schema);
208 208
 	}
209 209
 
210 210
 	/**
@@ -214,9 +214,9 @@  discard block
 block discarded – undo
214 214
 	 */
215 215
 	public function get_collection_params() {
216 216
 		$params             = array();
217
-		$params['context']  = $this->get_context_param( array( 'default' => 'view' ) );
217
+		$params['context']  = $this->get_context_param(array('default' => 'view'));
218 218
 		$params['page']     = array(
219
-			'description'       => __( 'Current page of the collection.', 'woocommerce' ),
219
+			'description'       => __('Current page of the collection.', 'woocommerce'),
220 220
 			'type'              => 'integer',
221 221
 			'default'           => 1,
222 222
 			'sanitize_callback' => 'absint',
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
 			'minimum'           => 1,
225 225
 		);
226 226
 		$params['per_page'] = array(
227
-			'description'       => __( 'Maximum number of items to be returned in result set.', 'woocommerce' ),
227
+			'description'       => __('Maximum number of items to be returned in result set.', 'woocommerce'),
228 228
 			'type'              => 'integer',
229 229
 			'default'           => 10,
230 230
 			'minimum'           => 1,
@@ -232,27 +232,27 @@  discard block
 block discarded – undo
232 232
 			'sanitize_callback' => 'absint',
233 233
 			'validate_callback' => 'rest_validate_request_arg',
234 234
 		);
235
-		$params['after']    = array(
236
-			'description'       => __( 'Limit response to resources published after a given ISO8601 compliant date.', 'woocommerce' ),
235
+		$params['after'] = array(
236
+			'description'       => __('Limit response to resources published after a given ISO8601 compliant date.', 'woocommerce'),
237 237
 			'type'              => 'string',
238 238
 			'format'            => 'date-time',
239 239
 			'validate_callback' => 'rest_validate_request_arg',
240 240
 		);
241
-		$params['before']   = array(
242
-			'description'       => __( 'Limit response to resources published before a given ISO8601 compliant date.', 'woocommerce' ),
241
+		$params['before'] = array(
242
+			'description'       => __('Limit response to resources published before a given ISO8601 compliant date.', 'woocommerce'),
243 243
 			'type'              => 'string',
244 244
 			'format'            => 'date-time',
245 245
 			'validate_callback' => 'rest_validate_request_arg',
246 246
 		);
247
-		$params['order']    = array(
248
-			'description'       => __( 'Order sort attribute ascending or descending.', 'woocommerce' ),
247
+		$params['order'] = array(
248
+			'description'       => __('Order sort attribute ascending or descending.', 'woocommerce'),
249 249
 			'type'              => 'string',
250 250
 			'default'           => 'desc',
251
-			'enum'              => array( 'asc', 'desc' ),
251
+			'enum'              => array('asc', 'desc'),
252 252
 			'validate_callback' => 'rest_validate_request_arg',
253 253
 		);
254
-		$params['orderby']  = array(
255
-			'description'       => __( 'Sort collection by object attribute.', 'woocommerce' ),
254
+		$params['orderby'] = array(
255
+			'description'       => __('Sort collection by object attribute.', 'woocommerce'),
256 256
 			'type'              => 'string',
257 257
 			'default'           => 'tax_rate_id',
258 258
 			'enum'              => array(
@@ -267,8 +267,8 @@  discard block
 block discarded – undo
267 267
 			),
268 268
 			'validate_callback' => 'rest_validate_request_arg',
269 269
 		);
270
-		$params['taxes']    = array(
271
-			'description'       => __( 'Limit result set to items assigned one or more tax rates.', 'woocommerce' ),
270
+		$params['taxes'] = array(
271
+			'description'       => __('Limit result set to items assigned one or more tax rates.', 'woocommerce'),
272 272
 			'type'              => 'array',
273 273
 			'sanitize_callback' => 'wp_parse_id_list',
274 274
 			'validate_callback' => 'rest_validate_request_arg',
Please login to merge, or discard this patch.
src/RestApi/Version4/Controllers/Reports/Downloads.php 1 patch
Spacing   +94 added lines, -94 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
 
10 10
 namespace WooCommerce\RestApi\Version4\Controllers\Reports;
11 11
 
12
-defined( 'ABSPATH' ) || exit;
12
+defined('ABSPATH') || exit;
13 13
 
14 14
 use \WooCommerce\RestApi\Version4\Controllers\Reports as Reports;
15 15
 
@@ -31,45 +31,45 @@  discard block
 block discarded – undo
31 31
 	 * @param \WP_REST_Request $request Request data.
32 32
 	 * @return array|\WP_Error
33 33
 	 */
34
-	public function get_items( $request ) {
34
+	public function get_items($request) {
35 35
 		$args       = array();
36
-		$registered = array_keys( $this->get_collection_params() );
37
-		foreach ( $registered as $param_name ) {
38
-			if ( isset( $request[ $param_name ] ) ) {
39
-				$args[ $param_name ] = $request[ $param_name ];
36
+		$registered = array_keys($this->get_collection_params());
37
+		foreach ($registered as $param_name) {
38
+			if (isset($request[$param_name])) {
39
+				$args[$param_name] = $request[$param_name];
40 40
 			}
41 41
 		}
42 42
 
43
-		$reports        = new \WC_Admin_Reports_Downloads_Query( $args );
43
+		$reports        = new \WC_Admin_Reports_Downloads_Query($args);
44 44
 		$downloads_data = $reports->get_data();
45 45
 
46 46
 		$data = array();
47 47
 
48
-		foreach ( $downloads_data->data as $download_data ) {
49
-			$item   = $this->prepare_item_for_response( $download_data, $request );
50
-			$data[] = $this->prepare_response_for_collection( $item );
48
+		foreach ($downloads_data->data as $download_data) {
49
+			$item   = $this->prepare_item_for_response($download_data, $request);
50
+			$data[] = $this->prepare_response_for_collection($item);
51 51
 		}
52 52
 
53
-		$response = rest_ensure_response( $data );
53
+		$response = rest_ensure_response($data);
54 54
 
55
-		$response->header( 'X-WP-Total', (int) $downloads_data->total );
56
-		$response->header( 'X-WP-TotalPages', (int) $downloads_data->pages );
55
+		$response->header('X-WP-Total', (int) $downloads_data->total);
56
+		$response->header('X-WP-TotalPages', (int) $downloads_data->pages);
57 57
 
58 58
 		$page      = $downloads_data->page_no;
59 59
 		$max_pages = $downloads_data->pages;
60
-		$base      = add_query_arg( $request->get_query_params(), rest_url( sprintf( '/%s/%s', $this->namespace, $this->rest_base ) ) );
61
-		if ( $page > 1 ) {
60
+		$base      = add_query_arg($request->get_query_params(), rest_url(sprintf('/%s/%s', $this->namespace, $this->rest_base)));
61
+		if ($page > 1) {
62 62
 			$prev_page = $page - 1;
63
-			if ( $prev_page > $max_pages ) {
63
+			if ($prev_page > $max_pages) {
64 64
 				$prev_page = $max_pages;
65 65
 			}
66
-			$prev_link = add_query_arg( 'page', $prev_page, $base );
67
-			$response->link_header( 'prev', $prev_link );
66
+			$prev_link = add_query_arg('page', $prev_page, $base);
67
+			$response->link_header('prev', $prev_link);
68 68
 		}
69
-		if ( $max_pages > $page ) {
69
+		if ($max_pages > $page) {
70 70
 			$next_page = $page + 1;
71
-			$next_link = add_query_arg( 'page', $next_page, $base );
72
-			$response->link_header( 'next', $next_link );
71
+			$next_link = add_query_arg('page', $next_page, $base);
72
+			$response->link_header('next', $next_link);
73 73
 		}
74 74
 
75 75
 		return $response;
@@ -82,30 +82,30 @@  discard block
 block discarded – undo
82 82
 	 * @param \WP_REST_Request $request Request object.
83 83
 	 * @return \WP_REST_Response
84 84
 	 */
85
-	public function prepare_item_for_response( $report, $request ) {
85
+	public function prepare_item_for_response($report, $request) {
86 86
 		$data = $report;
87 87
 
88
-		$context = ! empty( $request['context'] ) ? $request['context'] : 'view';
89
-		$data    = $this->add_additional_fields_to_object( $data, $request );
90
-		$data    = $this->filter_response_by_context( $data, $context );
88
+		$context = ! empty($request['context']) ? $request['context'] : 'view';
89
+		$data    = $this->add_additional_fields_to_object($data, $request);
90
+		$data    = $this->filter_response_by_context($data, $context);
91 91
 
92 92
 		// Wrap the data in a response object.
93
-		$response = rest_ensure_response( $data );
94
-		$response->add_links( $this->prepare_links( $report ) );
93
+		$response = rest_ensure_response($data);
94
+		$response->add_links($this->prepare_links($report));
95 95
 
96
-		$response->data['date'] = get_date_from_gmt( $data['date_gmt'], 'Y-m-d H:i:s' );
96
+		$response->data['date'] = get_date_from_gmt($data['date_gmt'], 'Y-m-d H:i:s');
97 97
 
98 98
 		// Figure out file name.
99 99
 		// Matches https://github.com/woocommerce/woocommerce/blob/4be0018c092e617c5d2b8c46b800eb71ece9ddef/includes/class-wc-download-handler.php#L197.
100
-		$product_id                     = intval( $data['product_id'] );
101
-		$_product                       = wc_get_product( $product_id );
102
-		$file_path                      = $_product->get_file_download_path( $data['download_id'] );
103
-		$filename                       = basename( $file_path );
104
-		$response->data['file_name']    = apply_filters( 'woocommerce_file_download_filename', $filename, $product_id );
100
+		$product_id                     = intval($data['product_id']);
101
+		$_product                       = wc_get_product($product_id);
102
+		$file_path                      = $_product->get_file_download_path($data['download_id']);
103
+		$filename                       = basename($file_path);
104
+		$response->data['file_name']    = apply_filters('woocommerce_file_download_filename', $filename, $product_id);
105 105
 		$response->data['file_path']    = $file_path;
106
-		$customer                       = new \WC_Customer( $data['user_id'] );
106
+		$customer                       = new \WC_Customer($data['user_id']);
107 107
 		$response->data['username']     = $customer->get_username();
108
-		$response->data['order_number'] = $this->get_order_number( $data['order_id'] );
108
+		$response->data['order_number'] = $this->get_order_number($data['order_id']);
109 109
 
110 110
 		/**
111 111
 		 * Filter a report returned from the API.
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 		 * @param object           $report   The original report object.
117 117
 		 * @param \WP_REST_Request  $request  Request used to generate the response.
118 118
 		 */
119
-		return apply_filters( 'woocommerce_rest_prepare_report_downloads', $response, $report, $request );
119
+		return apply_filters('woocommerce_rest_prepare_report_downloads', $response, $report, $request);
120 120
 	}
121 121
 
122 122
 	/**
@@ -125,10 +125,10 @@  discard block
 block discarded – undo
125 125
 	 * @param Array $object Object data.
126 126
 	 * @return array        Links for the given post.
127 127
 	 */
128
-	protected function prepare_links( $object ) {
128
+	protected function prepare_links($object) {
129 129
 		$links = array(
130 130
 			'product' => array(
131
-				'href'       => rest_url( sprintf( '/%s/%s/%d', $this->namespace, 'products', $object['product_id'] ) ),
131
+				'href'       => rest_url(sprintf('/%s/%s/%d', $this->namespace, 'products', $object['product_id'])),
132 132
 				'embeddable' => true,
133 133
 			),
134 134
 		);
@@ -150,85 +150,85 @@  discard block
 block discarded – undo
150 150
 				'id'           => array(
151 151
 					'type'        => 'integer',
152 152
 					'readonly'    => true,
153
-					'context'     => array( 'view', 'edit' ),
154
-					'description' => __( 'ID.', 'woocommerce' ),
153
+					'context'     => array('view', 'edit'),
154
+					'description' => __('ID.', 'woocommerce'),
155 155
 				),
156 156
 				'product_id'   => array(
157 157
 					'type'        => 'integer',
158 158
 					'readonly'    => true,
159
-					'context'     => array( 'view', 'edit' ),
160
-					'description' => __( 'Product ID.', 'woocommerce' ),
159
+					'context'     => array('view', 'edit'),
160
+					'description' => __('Product ID.', 'woocommerce'),
161 161
 				),
162 162
 				'date'         => array(
163
-					'description' => __( "The date of the download, in the site's timezone.", 'woocommerce' ),
163
+					'description' => __("The date of the download, in the site's timezone.", 'woocommerce'),
164 164
 					'type'        => 'date-time',
165
-					'context'     => array( 'view', 'edit' ),
165
+					'context'     => array('view', 'edit'),
166 166
 					'readonly'    => true,
167 167
 				),
168 168
 				'date_gmt'     => array(
169
-					'description' => __( 'The date of the download, as GMT.', 'woocommerce' ),
169
+					'description' => __('The date of the download, as GMT.', 'woocommerce'),
170 170
 					'type'        => 'date-time',
171
-					'context'     => array( 'view', 'edit' ),
171
+					'context'     => array('view', 'edit'),
172 172
 					'readonly'    => true,
173 173
 				),
174 174
 				'download_id'  => array(
175 175
 					'type'        => 'string',
176 176
 					'readonly'    => true,
177
-					'context'     => array( 'view', 'edit' ),
178
-					'description' => __( 'Download ID.', 'woocommerce' ),
177
+					'context'     => array('view', 'edit'),
178
+					'description' => __('Download ID.', 'woocommerce'),
179 179
 				),
180 180
 				'file_name'    => array(
181 181
 					'type'        => 'string',
182 182
 					'readonly'    => true,
183
-					'context'     => array( 'view', 'edit' ),
184
-					'description' => __( 'File name.', 'woocommerce' ),
183
+					'context'     => array('view', 'edit'),
184
+					'description' => __('File name.', 'woocommerce'),
185 185
 				),
186 186
 				'file_path'    => array(
187 187
 					'type'        => 'string',
188 188
 					'readonly'    => true,
189
-					'context'     => array( 'view', 'edit' ),
190
-					'description' => __( 'File URL.', 'woocommerce' ),
189
+					'context'     => array('view', 'edit'),
190
+					'description' => __('File URL.', 'woocommerce'),
191 191
 				),
192 192
 				'product_id'   => array(
193 193
 					'type'        => 'integer',
194 194
 					'readonly'    => true,
195
-					'context'     => array( 'view', 'edit' ),
196
-					'description' => __( 'Product ID.', 'woocommerce' ),
195
+					'context'     => array('view', 'edit'),
196
+					'description' => __('Product ID.', 'woocommerce'),
197 197
 				),
198 198
 				'order_id'     => array(
199 199
 					'type'        => 'integer',
200 200
 					'readonly'    => true,
201
-					'context'     => array( 'view', 'edit' ),
202
-					'description' => __( 'Order ID.', 'woocommerce' ),
201
+					'context'     => array('view', 'edit'),
202
+					'description' => __('Order ID.', 'woocommerce'),
203 203
 				),
204 204
 				'order_number' => array(
205 205
 					'type'        => 'string',
206 206
 					'readonly'    => true,
207
-					'context'     => array( 'view', 'edit' ),
208
-					'description' => __( 'Order Number.', 'woocommerce' ),
207
+					'context'     => array('view', 'edit'),
208
+					'description' => __('Order Number.', 'woocommerce'),
209 209
 				),
210 210
 				'user_id'      => array(
211 211
 					'type'        => 'integer',
212 212
 					'readonly'    => true,
213
-					'context'     => array( 'view', 'edit' ),
214
-					'description' => __( 'User ID for the downloader.', 'woocommerce' ),
213
+					'context'     => array('view', 'edit'),
214
+					'description' => __('User ID for the downloader.', 'woocommerce'),
215 215
 				),
216 216
 				'username'     => array(
217 217
 					'type'        => 'string',
218 218
 					'readonly'    => true,
219
-					'context'     => array( 'view', 'edit' ),
220
-					'description' => __( 'User name of the downloader.', 'woocommerce' ),
219
+					'context'     => array('view', 'edit'),
220
+					'description' => __('User name of the downloader.', 'woocommerce'),
221 221
 				),
222 222
 				'ip_address'   => array(
223 223
 					'type'        => 'string',
224 224
 					'readonly'    => true,
225
-					'context'     => array( 'view', 'edit' ),
226
-					'description' => __( 'IP address for the downloader.', 'woocommerce' ),
225
+					'context'     => array('view', 'edit'),
226
+					'description' => __('IP address for the downloader.', 'woocommerce'),
227 227
 				),
228 228
 			),
229 229
 		);
230 230
 
231
-		return $this->add_additional_fields_schema( $schema );
231
+		return $this->add_additional_fields_schema($schema);
232 232
 	}
233 233
 
234 234
 	/**
@@ -238,17 +238,17 @@  discard block
 block discarded – undo
238 238
 	 */
239 239
 	public function get_collection_params() {
240 240
 		$params                        = array();
241
-		$params['context']             = $this->get_context_param( array( 'default' => 'view' ) );
241
+		$params['context']             = $this->get_context_param(array('default' => 'view'));
242 242
 		$params['page']                = array(
243
-			'description'       => __( 'Current page of the collection.', 'woocommerce' ),
243
+			'description'       => __('Current page of the collection.', 'woocommerce'),
244 244
 			'type'              => 'integer',
245 245
 			'default'           => 1,
246 246
 			'sanitize_callback' => 'absint',
247 247
 			'validate_callback' => 'rest_validate_request_arg',
248 248
 			'minimum'           => 1,
249 249
 		);
250
-		$params['per_page']            = array(
251
-			'description'       => __( 'Maximum number of items to be returned in result set.', 'woocommerce' ),
250
+		$params['per_page'] = array(
251
+			'description'       => __('Maximum number of items to be returned in result set.', 'woocommerce'),
252 252
 			'type'              => 'integer',
253 253
 			'default'           => 10,
254 254
 			'minimum'           => 1,
@@ -256,27 +256,27 @@  discard block
 block discarded – undo
256 256
 			'sanitize_callback' => 'absint',
257 257
 			'validate_callback' => 'rest_validate_request_arg',
258 258
 		);
259
-		$params['after']               = array(
260
-			'description'       => __( 'Limit response to resources published after a given ISO8601 compliant date.', 'woocommerce' ),
259
+		$params['after'] = array(
260
+			'description'       => __('Limit response to resources published after a given ISO8601 compliant date.', 'woocommerce'),
261 261
 			'type'              => 'string',
262 262
 			'format'            => 'date-time',
263 263
 			'validate_callback' => 'rest_validate_request_arg',
264 264
 		);
265
-		$params['before']              = array(
266
-			'description'       => __( 'Limit response to resources published before a given ISO8601 compliant date.', 'woocommerce' ),
265
+		$params['before'] = array(
266
+			'description'       => __('Limit response to resources published before a given ISO8601 compliant date.', 'woocommerce'),
267 267
 			'type'              => 'string',
268 268
 			'format'            => 'date-time',
269 269
 			'validate_callback' => 'rest_validate_request_arg',
270 270
 		);
271
-		$params['order']               = array(
272
-			'description'       => __( 'Order sort attribute ascending or descending.', 'woocommerce' ),
271
+		$params['order'] = array(
272
+			'description'       => __('Order sort attribute ascending or descending.', 'woocommerce'),
273 273
 			'type'              => 'string',
274 274
 			'default'           => 'desc',
275
-			'enum'              => array( 'asc', 'desc' ),
275
+			'enum'              => array('asc', 'desc'),
276 276
 			'validate_callback' => 'rest_validate_request_arg',
277 277
 		);
278
-		$params['orderby']             = array(
279
-			'description'       => __( 'Sort collection by object attribute.', 'woocommerce' ),
278
+		$params['orderby'] = array(
279
+			'description'       => __('Sort collection by object attribute.', 'woocommerce'),
280 280
 			'type'              => 'string',
281 281
 			'default'           => 'date',
282 282
 			'enum'              => array(
@@ -285,8 +285,8 @@  discard block
 block discarded – undo
285 285
 			),
286 286
 			'validate_callback' => 'rest_validate_request_arg',
287 287
 		);
288
-		$params['match']               = array(
289
-			'description'       => __( 'Indicates whether all the conditions should be true for the resulting set, or if any one of them is sufficient. Match affects the following parameters: products, orders, username, ip_address.', 'woocommerce' ),
288
+		$params['match'] = array(
289
+			'description'       => __('Indicates whether all the conditions should be true for the resulting set, or if any one of them is sufficient. Match affects the following parameters: products, orders, username, ip_address.', 'woocommerce'),
290 290
 			'type'              => 'string',
291 291
 			'default'           => 'all',
292 292
 			'enum'              => array(
@@ -295,8 +295,8 @@  discard block
 block discarded – undo
295 295
 			),
296 296
 			'validate_callback' => 'rest_validate_request_arg',
297 297
 		);
298
-		$params['product_includes']    = array(
299
-			'description'       => __( 'Limit result set to items that have the specified product(s) assigned.', 'woocommerce' ),
298
+		$params['product_includes'] = array(
299
+			'description'       => __('Limit result set to items that have the specified product(s) assigned.', 'woocommerce'),
300 300
 			'type'              => 'array',
301 301
 			'items'             => array(
302 302
 				'type' => 'integer',
@@ -305,8 +305,8 @@  discard block
 block discarded – undo
305 305
 			'sanitize_callback' => 'wp_parse_id_list',
306 306
 			'validate_callback' => 'rest_validate_request_arg',
307 307
 		);
308
-		$params['product_excludes']    = array(
309
-			'description'       => __( 'Limit result set to items that don\'t have the specified product(s) assigned.', 'woocommerce' ),
308
+		$params['product_excludes'] = array(
309
+			'description'       => __('Limit result set to items that don\'t have the specified product(s) assigned.', 'woocommerce'),
310 310
 			'type'              => 'array',
311 311
 			'items'             => array(
312 312
 				'type' => 'integer',
@@ -315,8 +315,8 @@  discard block
 block discarded – undo
315 315
 			'validate_callback' => 'rest_validate_request_arg',
316 316
 			'sanitize_callback' => 'wp_parse_id_list',
317 317
 		);
318
-		$params['order_includes']      = array(
319
-			'description'       => __( 'Limit result set to items that have the specified order ids.', 'woocommerce' ),
318
+		$params['order_includes'] = array(
319
+			'description'       => __('Limit result set to items that have the specified order ids.', 'woocommerce'),
320 320
 			'type'              => 'array',
321 321
 			'sanitize_callback' => 'wp_parse_id_list',
322 322
 			'validate_callback' => 'rest_validate_request_arg',
@@ -324,8 +324,8 @@  discard block
 block discarded – undo
324 324
 				'type' => 'integer',
325 325
 			),
326 326
 		);
327
-		$params['order_excludes']      = array(
328
-			'description'       => __( 'Limit result set to items that don\'t have the specified order ids.', 'woocommerce' ),
327
+		$params['order_excludes'] = array(
328
+			'description'       => __('Limit result set to items that don\'t have the specified order ids.', 'woocommerce'),
329 329
 			'type'              => 'array',
330 330
 			'sanitize_callback' => 'wp_parse_id_list',
331 331
 			'validate_callback' => 'rest_validate_request_arg',
@@ -333,8 +333,8 @@  discard block
 block discarded – undo
333 333
 				'type' => 'integer',
334 334
 			),
335 335
 		);
336
-		$params['customer_includes']   = array(
337
-			'description'       => __( 'Limit response to objects that have the specified user ids.', 'woocommerce' ),
336
+		$params['customer_includes'] = array(
337
+			'description'       => __('Limit response to objects that have the specified user ids.', 'woocommerce'),
338 338
 			'type'              => 'array',
339 339
 			'sanitize_callback' => 'wp_parse_id_list',
340 340
 			'validate_callback' => 'rest_validate_request_arg',
@@ -342,8 +342,8 @@  discard block
 block discarded – undo
342 342
 				'type' => 'integer',
343 343
 			),
344 344
 		);
345
-		$params['customer_excludes']   = array(
346
-			'description'       => __( 'Limit response to objects that don\'t have the specified user ids.', 'woocommerce' ),
345
+		$params['customer_excludes'] = array(
346
+			'description'       => __('Limit response to objects that don\'t have the specified user ids.', 'woocommerce'),
347 347
 			'type'              => 'array',
348 348
 			'sanitize_callback' => 'wp_parse_id_list',
349 349
 			'validate_callback' => 'rest_validate_request_arg',
@@ -352,7 +352,7 @@  discard block
 block discarded – undo
352 352
 			),
353 353
 		);
354 354
 		$params['ip_address_includes'] = array(
355
-			'description'       => __( 'Limit response to objects that have a specified ip address.', 'woocommerce' ),
355
+			'description'       => __('Limit response to objects that have a specified ip address.', 'woocommerce'),
356 356
 			'type'              => 'array',
357 357
 			'validate_callback' => 'rest_validate_request_arg',
358 358
 			'items'             => array(
@@ -361,7 +361,7 @@  discard block
 block discarded – undo
361 361
 		);
362 362
 
363 363
 		$params['ip_address_excludes'] = array(
364
-			'description'       => __( 'Limit response to objects that don\'t have a specified ip address.', 'woocommerce' ),
364
+			'description'       => __('Limit response to objects that don\'t have a specified ip address.', 'woocommerce'),
365 365
 			'type'              => 'array',
366 366
 			'validate_callback' => 'rest_validate_request_arg',
367 367
 			'items'             => array(
Please login to merge, or discard this patch.
src/RestApi/Version4/Controllers/Reports/OrderStats.php 1 patch
Spacing   +108 added lines, -108 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
 
10 10
 namespace WooCommerce\RestApi\Version4\Controllers\Reports;
11 11
 
12
-defined( 'ABSPATH' ) || exit;
12
+defined('ABSPATH') || exit;
13 13
 
14 14
 use \WooCommerce\RestApi\Version4\Controllers\Reports as Reports;
15 15
 
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 	 * @param array $request Request array.
32 32
 	 * @return array
33 33
 	 */
34
-	protected function prepare_reports_query( $request ) {
34
+	protected function prepare_reports_query($request) {
35 35
 		$args             = array();
36 36
 		$args['before']   = $request['before'];
37 37
 		$args['after']    = $request['after'];
@@ -62,44 +62,44 @@  discard block
 block discarded – undo
62 62
 	 * @param \WP_REST_Request $request Request data.
63 63
 	 * @return array|\WP_Error
64 64
 	 */
65
-	public function get_items( $request ) {
66
-		$query_args   = $this->prepare_reports_query( $request );
67
-		$orders_query = new \WC_Admin_Reports_Orders_Stats_Query( $query_args );
65
+	public function get_items($request) {
66
+		$query_args   = $this->prepare_reports_query($request);
67
+		$orders_query = new \WC_Admin_Reports_Orders_Stats_Query($query_args);
68 68
 		try {
69 69
 			$report_data = $orders_query->get_data();
70
-		} catch ( \WC_Admin_Reports_Parameter_Exception $e ) {
71
-			return new \WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) );
70
+		} catch (\WC_Admin_Reports_Parameter_Exception $e) {
71
+			return new \WP_Error($e->getErrorCode(), $e->getMessage(), array('status' => $e->getCode()));
72 72
 		}
73 73
 
74 74
 		$out_data = array(
75
-			'totals'    => get_object_vars( $report_data->totals ),
75
+			'totals'    => get_object_vars($report_data->totals),
76 76
 			'intervals' => array(),
77 77
 		);
78 78
 
79
-		foreach ( $report_data->intervals as $interval_data ) {
80
-			$item                    = $this->prepare_item_for_response( $interval_data, $request );
81
-			$out_data['intervals'][] = $this->prepare_response_for_collection( $item );
79
+		foreach ($report_data->intervals as $interval_data) {
80
+			$item                    = $this->prepare_item_for_response($interval_data, $request);
81
+			$out_data['intervals'][] = $this->prepare_response_for_collection($item);
82 82
 		}
83 83
 
84
-		$response = rest_ensure_response( $out_data );
85
-		$response->header( 'X-WP-Total', (int) $report_data->total );
86
-		$response->header( 'X-WP-TotalPages', (int) $report_data->pages );
84
+		$response = rest_ensure_response($out_data);
85
+		$response->header('X-WP-Total', (int) $report_data->total);
86
+		$response->header('X-WP-TotalPages', (int) $report_data->pages);
87 87
 
88 88
 		$page      = $report_data->page_no;
89 89
 		$max_pages = $report_data->pages;
90
-		$base      = add_query_arg( $request->get_query_params(), rest_url( sprintf( '/%s/%s', $this->namespace, $this->rest_base ) ) );
91
-		if ( $page > 1 ) {
90
+		$base      = add_query_arg($request->get_query_params(), rest_url(sprintf('/%s/%s', $this->namespace, $this->rest_base)));
91
+		if ($page > 1) {
92 92
 			$prev_page = $page - 1;
93
-			if ( $prev_page > $max_pages ) {
93
+			if ($prev_page > $max_pages) {
94 94
 				$prev_page = $max_pages;
95 95
 			}
96
-			$prev_link = add_query_arg( 'page', $prev_page, $base );
97
-			$response->link_header( 'prev', $prev_link );
96
+			$prev_link = add_query_arg('page', $prev_page, $base);
97
+			$response->link_header('prev', $prev_link);
98 98
 		}
99
-		if ( $max_pages > $page ) {
99
+		if ($max_pages > $page) {
100 100
 			$next_page = $page + 1;
101
-			$next_link = add_query_arg( 'page', $next_page, $base );
102
-			$response->link_header( 'next', $next_link );
101
+			$next_link = add_query_arg('page', $next_page, $base);
102
+			$response->link_header('next', $next_link);
103 103
 		}
104 104
 
105 105
 		return $response;
@@ -112,15 +112,15 @@  discard block
 block discarded – undo
112 112
 	 * @param \WP_REST_Request $request Request object.
113 113
 	 * @return \WP_REST_Response
114 114
 	 */
115
-	public function prepare_item_for_response( $report, $request ) {
115
+	public function prepare_item_for_response($report, $request) {
116 116
 		$data = $report;
117 117
 
118
-		$context = ! empty( $request['context'] ) ? $request['context'] : 'view';
119
-		$data    = $this->add_additional_fields_to_object( $data, $request );
120
-		$data    = $this->filter_response_by_context( $data, $context );
118
+		$context = ! empty($request['context']) ? $request['context'] : 'view';
119
+		$data    = $this->add_additional_fields_to_object($data, $request);
120
+		$data    = $this->filter_response_by_context($data, $context);
121 121
 
122 122
 		// Wrap the data in a response object.
123
-		$response = rest_ensure_response( $data );
123
+		$response = rest_ensure_response($data);
124 124
 
125 125
 		/**
126 126
 		 * Filter a report returned from the API.
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 		 * @param object           $report   The original report object.
132 132
 		 * @param \WP_REST_Request  $request  Request used to generate the response.
133 133
 		 */
134
-		return apply_filters( 'woocommerce_rest_prepare_report_orders_stats', $response, $report, $request );
134
+		return apply_filters('woocommerce_rest_prepare_report_orders_stats', $response, $report, $request);
135 135
 	}
136 136
 
137 137
 	/**
@@ -142,90 +142,90 @@  discard block
 block discarded – undo
142 142
 	public function get_item_schema() {
143 143
 		$data_values = array(
144 144
 			'net_revenue'             => array(
145
-				'description' => __( 'Net revenue.', 'woocommerce' ),
145
+				'description' => __('Net revenue.', 'woocommerce'),
146 146
 				'type'        => 'number',
147
-				'context'     => array( 'view', 'edit' ),
147
+				'context'     => array('view', 'edit'),
148 148
 				'readonly'    => true,
149 149
 				'format'      => 'currency',
150 150
 			),
151 151
 			'orders_count'            => array(
152
-				'description' => __( 'Amount of orders', 'woocommerce' ),
152
+				'description' => __('Amount of orders', 'woocommerce'),
153 153
 				'type'        => 'integer',
154
-				'context'     => array( 'view', 'edit' ),
154
+				'context'     => array('view', 'edit'),
155 155
 				'readonly'    => true,
156 156
 				'indicator'   => true,
157 157
 			),
158 158
 			'avg_order_value'         => array(
159
-				'description' => __( 'Average order value.', 'woocommerce' ),
159
+				'description' => __('Average order value.', 'woocommerce'),
160 160
 				'type'        => 'number',
161
-				'context'     => array( 'view', 'edit' ),
161
+				'context'     => array('view', 'edit'),
162 162
 				'readonly'    => true,
163 163
 				'indicator'   => true,
164 164
 				'format'      => 'currency',
165 165
 			),
166 166
 			'avg_items_per_order'     => array(
167
-				'description' => __( 'Average items per order', 'woocommerce' ),
167
+				'description' => __('Average items per order', 'woocommerce'),
168 168
 				'type'        => 'number',
169
-				'context'     => array( 'view', 'edit' ),
169
+				'context'     => array('view', 'edit'),
170 170
 				'readonly'    => true,
171 171
 			),
172 172
 			'num_items_sold'          => array(
173
-				'description' => __( 'Number of items sold', 'woocommerce' ),
173
+				'description' => __('Number of items sold', 'woocommerce'),
174 174
 				'type'        => 'integer',
175
-				'context'     => array( 'view', 'edit' ),
175
+				'context'     => array('view', 'edit'),
176 176
 				'readonly'    => true,
177 177
 			),
178 178
 			'coupons'                 => array(
179
-				'description' => __( 'Amount discounted by coupons.', 'woocommerce' ),
179
+				'description' => __('Amount discounted by coupons.', 'woocommerce'),
180 180
 				'type'        => 'number',
181
-				'context'     => array( 'view', 'edit' ),
181
+				'context'     => array('view', 'edit'),
182 182
 				'readonly'    => true,
183 183
 			),
184 184
 			'coupons_count'           => array(
185
-				'description' => __( 'Unique coupons count.', 'woocommerce' ),
185
+				'description' => __('Unique coupons count.', 'woocommerce'),
186 186
 				'type'        => 'number',
187
-				'context'     => array( 'view', 'edit' ),
187
+				'context'     => array('view', 'edit'),
188 188
 				'readonly'    => true,
189 189
 			),
190 190
 			'num_returning_customers' => array(
191
-				'description' => __( 'Number of orders done by returning customers', 'woocommerce' ),
191
+				'description' => __('Number of orders done by returning customers', 'woocommerce'),
192 192
 				'type'        => 'integer',
193
-				'context'     => array( 'view', 'edit' ),
193
+				'context'     => array('view', 'edit'),
194 194
 				'readonly'    => true,
195 195
 			),
196 196
 			'num_new_customers'       => array(
197
-				'description' => __( 'Number of orders done by new customers', 'woocommerce' ),
197
+				'description' => __('Number of orders done by new customers', 'woocommerce'),
198 198
 				'type'        => 'integer',
199
-				'context'     => array( 'view', 'edit' ),
199
+				'context'     => array('view', 'edit'),
200 200
 				'readonly'    => true,
201 201
 			),
202 202
 			'products'                => array(
203
-				'description' => __( 'Number of distinct products sold.', 'woocommerce' ),
203
+				'description' => __('Number of distinct products sold.', 'woocommerce'),
204 204
 				'type'        => 'number',
205
-				'context'     => array( 'view', 'edit' ),
205
+				'context'     => array('view', 'edit'),
206 206
 				'readonly'    => true,
207 207
 			),
208 208
 		);
209 209
 
210 210
 		$segments = array(
211 211
 			'segments' => array(
212
-				'description' => __( 'Reports data grouped by segment condition.', 'woocommerce' ),
212
+				'description' => __('Reports data grouped by segment condition.', 'woocommerce'),
213 213
 				'type'        => 'array',
214
-				'context'     => array( 'view', 'edit' ),
214
+				'context'     => array('view', 'edit'),
215 215
 				'readonly'    => true,
216 216
 				'items'       => array(
217 217
 					'type'       => 'object',
218 218
 					'properties' => array(
219 219
 						'segment_id' => array(
220
-							'description' => __( 'Segment identificator.', 'woocommerce' ),
220
+							'description' => __('Segment identificator.', 'woocommerce'),
221 221
 							'type'        => 'integer',
222
-							'context'     => array( 'view', 'edit' ),
222
+							'context'     => array('view', 'edit'),
223 223
 							'readonly'    => true,
224 224
 						),
225 225
 						'subtotals'  => array(
226
-							'description' => __( 'Interval subtotals.', 'woocommerce' ),
226
+							'description' => __('Interval subtotals.', 'woocommerce'),
227 227
 							'type'        => 'object',
228
-							'context'     => array( 'view', 'edit' ),
228
+							'context'     => array('view', 'edit'),
229 229
 							'readonly'    => true,
230 230
 							'properties'  => $data_values,
231 231
 						),
@@ -234,12 +234,12 @@  discard block
 block discarded – undo
234 234
 			),
235 235
 		);
236 236
 
237
-		$totals = array_merge( $data_values, $segments );
237
+		$totals = array_merge($data_values, $segments);
238 238
 
239 239
 		// Products is not shown in intervals.
240
-		unset( $data_values['products'] );
240
+		unset($data_values['products']);
241 241
 
242
-		$intervals = array_merge( $data_values, $segments );
242
+		$intervals = array_merge($data_values, $segments);
243 243
 
244 244
 		$schema = array(
245 245
 			'$schema'    => 'http://json-schema.org/draft-04/schema#',
@@ -247,55 +247,55 @@  discard block
 block discarded – undo
247 247
 			'type'       => 'object',
248 248
 			'properties' => array(
249 249
 				'totals'    => array(
250
-					'description' => __( 'Totals data.', 'woocommerce' ),
250
+					'description' => __('Totals data.', 'woocommerce'),
251 251
 					'type'        => 'object',
252
-					'context'     => array( 'view', 'edit' ),
252
+					'context'     => array('view', 'edit'),
253 253
 					'readonly'    => true,
254 254
 					'properties'  => $totals,
255 255
 				),
256 256
 				'intervals' => array(
257
-					'description' => __( 'Reports data grouped by intervals.', 'woocommerce' ),
257
+					'description' => __('Reports data grouped by intervals.', 'woocommerce'),
258 258
 					'type'        => 'array',
259
-					'context'     => array( 'view', 'edit' ),
259
+					'context'     => array('view', 'edit'),
260 260
 					'readonly'    => true,
261 261
 					'items'       => array(
262 262
 						'type'       => 'object',
263 263
 						'properties' => array(
264 264
 							'interval'       => array(
265
-								'description' => __( 'Type of interval.', 'woocommerce' ),
265
+								'description' => __('Type of interval.', 'woocommerce'),
266 266
 								'type'        => 'string',
267
-								'context'     => array( 'view', 'edit' ),
267
+								'context'     => array('view', 'edit'),
268 268
 								'readonly'    => true,
269
-								'enum'        => array( 'day', 'week', 'month', 'year' ),
269
+								'enum'        => array('day', 'week', 'month', 'year'),
270 270
 							),
271 271
 							'date_start'     => array(
272
-								'description' => __( "The date the report start, in the site's timezone.", 'woocommerce' ),
272
+								'description' => __("The date the report start, in the site's timezone.", 'woocommerce'),
273 273
 								'type'        => 'date-time',
274
-								'context'     => array( 'view', 'edit' ),
274
+								'context'     => array('view', 'edit'),
275 275
 								'readonly'    => true,
276 276
 							),
277 277
 							'date_start_gmt' => array(
278
-								'description' => __( 'The date the report start, as GMT.', 'woocommerce' ),
278
+								'description' => __('The date the report start, as GMT.', 'woocommerce'),
279 279
 								'type'        => 'date-time',
280
-								'context'     => array( 'view', 'edit' ),
280
+								'context'     => array('view', 'edit'),
281 281
 								'readonly'    => true,
282 282
 							),
283 283
 							'date_end'       => array(
284
-								'description' => __( "The date the report end, in the site's timezone.", 'woocommerce' ),
284
+								'description' => __("The date the report end, in the site's timezone.", 'woocommerce'),
285 285
 								'type'        => 'date-time',
286
-								'context'     => array( 'view', 'edit' ),
286
+								'context'     => array('view', 'edit'),
287 287
 								'readonly'    => true,
288 288
 							),
289 289
 							'date_end_gmt'   => array(
290
-								'description' => __( 'The date the report end, as GMT.', 'woocommerce' ),
290
+								'description' => __('The date the report end, as GMT.', 'woocommerce'),
291 291
 								'type'        => 'date-time',
292
-								'context'     => array( 'view', 'edit' ),
292
+								'context'     => array('view', 'edit'),
293 293
 								'readonly'    => true,
294 294
 							),
295 295
 							'subtotals'      => array(
296
-								'description' => __( 'Interval subtotals.', 'woocommerce' ),
296
+								'description' => __('Interval subtotals.', 'woocommerce'),
297 297
 								'type'        => 'object',
298
-								'context'     => array( 'view', 'edit' ),
298
+								'context'     => array('view', 'edit'),
299 299
 								'readonly'    => true,
300 300
 								'properties'  => $intervals,
301 301
 							),
@@ -305,7 +305,7 @@  discard block
 block discarded – undo
305 305
 			),
306 306
 		);
307 307
 
308
-		return $this->add_additional_fields_schema( $schema );
308
+		return $this->add_additional_fields_schema($schema);
309 309
 	}
310 310
 
311 311
 	/**
@@ -315,17 +315,17 @@  discard block
 block discarded – undo
315 315
 	 */
316 316
 	public function get_collection_params() {
317 317
 		$params                     = array();
318
-		$params['context']          = $this->get_context_param( array( 'default' => 'view' ) );
318
+		$params['context']          = $this->get_context_param(array('default' => 'view'));
319 319
 		$params['page']             = array(
320
-			'description'       => __( 'Current page of the collection.', 'woocommerce' ),
320
+			'description'       => __('Current page of the collection.', 'woocommerce'),
321 321
 			'type'              => 'integer',
322 322
 			'default'           => 1,
323 323
 			'sanitize_callback' => 'absint',
324 324
 			'validate_callback' => 'rest_validate_request_arg',
325 325
 			'minimum'           => 1,
326 326
 		);
327
-		$params['per_page']         = array(
328
-			'description'       => __( 'Maximum number of items to be returned in result set.', 'woocommerce' ),
327
+		$params['per_page'] = array(
328
+			'description'       => __('Maximum number of items to be returned in result set.', 'woocommerce'),
329 329
 			'type'              => 'integer',
330 330
 			'default'           => 10,
331 331
 			'minimum'           => 1,
@@ -333,27 +333,27 @@  discard block
 block discarded – undo
333 333
 			'sanitize_callback' => 'absint',
334 334
 			'validate_callback' => 'rest_validate_request_arg',
335 335
 		);
336
-		$params['after']            = array(
337
-			'description'       => __( 'Limit response to resources published after a given ISO8601 compliant date.', 'woocommerce' ),
336
+		$params['after'] = array(
337
+			'description'       => __('Limit response to resources published after a given ISO8601 compliant date.', 'woocommerce'),
338 338
 			'type'              => 'string',
339 339
 			'format'            => 'date-time',
340 340
 			'validate_callback' => 'rest_validate_request_arg',
341 341
 		);
342
-		$params['before']           = array(
343
-			'description'       => __( 'Limit response to resources published before a given ISO8601 compliant date.', 'woocommerce' ),
342
+		$params['before'] = array(
343
+			'description'       => __('Limit response to resources published before a given ISO8601 compliant date.', 'woocommerce'),
344 344
 			'type'              => 'string',
345 345
 			'format'            => 'date-time',
346 346
 			'validate_callback' => 'rest_validate_request_arg',
347 347
 		);
348
-		$params['order']            = array(
349
-			'description'       => __( 'Order sort attribute ascending or descending.', 'woocommerce' ),
348
+		$params['order'] = array(
349
+			'description'       => __('Order sort attribute ascending or descending.', 'woocommerce'),
350 350
 			'type'              => 'string',
351 351
 			'default'           => 'desc',
352
-			'enum'              => array( 'asc', 'desc' ),
352
+			'enum'              => array('asc', 'desc'),
353 353
 			'validate_callback' => 'rest_validate_request_arg',
354 354
 		);
355
-		$params['orderby']          = array(
356
-			'description'       => __( 'Sort collection by object attribute.', 'woocommerce' ),
355
+		$params['orderby'] = array(
356
+			'description'       => __('Sort collection by object attribute.', 'woocommerce'),
357 357
 			'type'              => 'string',
358 358
 			'default'           => 'date',
359 359
 			'enum'              => array(
@@ -364,8 +364,8 @@  discard block
 block discarded – undo
364 364
 			),
365 365
 			'validate_callback' => 'rest_validate_request_arg',
366 366
 		);
367
-		$params['interval']         = array(
368
-			'description'       => __( 'Time interval to use for buckets in the returned data.', 'woocommerce' ),
367
+		$params['interval'] = array(
368
+			'description'       => __('Time interval to use for buckets in the returned data.', 'woocommerce'),
369 369
 			'type'              => 'string',
370 370
 			'default'           => 'week',
371 371
 			'enum'              => array(
@@ -378,8 +378,8 @@  discard block
 block discarded – undo
378 378
 			),
379 379
 			'validate_callback' => 'rest_validate_request_arg',
380 380
 		);
381
-		$params['match']            = array(
382
-			'description'       => __( 'Indicates whether all the conditions should be true for the resulting set, or if any one of them is sufficient. Match affects the following parameters: status_is, status_is_not, product_includes, product_excludes, coupon_includes, coupon_excludes, customer, categories', 'woocommerce' ),
381
+		$params['match'] = array(
382
+			'description'       => __('Indicates whether all the conditions should be true for the resulting set, or if any one of them is sufficient. Match affects the following parameters: status_is, status_is_not, product_includes, product_excludes, coupon_includes, coupon_excludes, customer, categories', 'woocommerce'),
383 383
 			'type'              => 'string',
384 384
 			'default'           => 'all',
385 385
 			'enum'              => array(
@@ -388,8 +388,8 @@  discard block
 block discarded – undo
388 388
 			),
389 389
 			'validate_callback' => 'rest_validate_request_arg',
390 390
 		);
391
-		$params['status_is']        = array(
392
-			'description'       => __( 'Limit result set to items that have the specified order status.', 'woocommerce' ),
391
+		$params['status_is'] = array(
392
+			'description'       => __('Limit result set to items that have the specified order status.', 'woocommerce'),
393 393
 			'type'              => 'array',
394 394
 			'sanitize_callback' => 'wp_parse_slug_list',
395 395
 			'validate_callback' => 'rest_validate_request_arg',
@@ -399,8 +399,8 @@  discard block
 block discarded – undo
399 399
 				'type' => 'string',
400 400
 			),
401 401
 		);
402
-		$params['status_is_not']    = array(
403
-			'description'       => __( 'Limit result set to items that don\'t have the specified order status.', 'woocommerce' ),
402
+		$params['status_is_not'] = array(
403
+			'description'       => __('Limit result set to items that don\'t have the specified order status.', 'woocommerce'),
404 404
 			'type'              => 'array',
405 405
 			'sanitize_callback' => 'wp_parse_slug_list',
406 406
 			'validate_callback' => 'rest_validate_request_arg',
@@ -410,7 +410,7 @@  discard block
 block discarded – undo
410 410
 			),
411 411
 		);
412 412
 		$params['product_includes'] = array(
413
-			'description'       => __( 'Limit result set to items that have the specified product(s) assigned.', 'woocommerce' ),
413
+			'description'       => __('Limit result set to items that have the specified product(s) assigned.', 'woocommerce'),
414 414
 			'type'              => 'array',
415 415
 			'items'             => array(
416 416
 				'type' => 'integer',
@@ -420,7 +420,7 @@  discard block
 block discarded – undo
420 420
 
421 421
 		);
422 422
 		$params['product_excludes'] = array(
423
-			'description'       => __( 'Limit result set to items that don\'t have the specified product(s) assigned.', 'woocommerce' ),
423
+			'description'       => __('Limit result set to items that don\'t have the specified product(s) assigned.', 'woocommerce'),
424 424
 			'type'              => 'array',
425 425
 			'items'             => array(
426 426
 				'type' => 'integer',
@@ -428,8 +428,8 @@  discard block
 block discarded – undo
428 428
 			'default'           => array(),
429 429
 			'sanitize_callback' => 'wp_parse_id_list',
430 430
 		);
431
-		$params['coupon_includes']  = array(
432
-			'description'       => __( 'Limit result set to items that have the specified coupon(s) assigned.', 'woocommerce' ),
431
+		$params['coupon_includes'] = array(
432
+			'description'       => __('Limit result set to items that have the specified coupon(s) assigned.', 'woocommerce'),
433 433
 			'type'              => 'array',
434 434
 			'items'             => array(
435 435
 				'type' => 'integer',
@@ -437,8 +437,8 @@  discard block
 block discarded – undo
437 437
 			'default'           => array(),
438 438
 			'sanitize_callback' => 'wp_parse_id_list',
439 439
 		);
440
-		$params['coupon_excludes']  = array(
441
-			'description'       => __( 'Limit result set to items that don\'t have the specified coupon(s) assigned.', 'woocommerce' ),
440
+		$params['coupon_excludes'] = array(
441
+			'description'       => __('Limit result set to items that don\'t have the specified coupon(s) assigned.', 'woocommerce'),
442 442
 			'type'              => 'array',
443 443
 			'items'             => array(
444 444
 				'type' => 'integer',
@@ -446,8 +446,8 @@  discard block
 block discarded – undo
446 446
 			'default'           => array(),
447 447
 			'sanitize_callback' => 'wp_parse_id_list',
448 448
 		);
449
-		$params['customer']         = array(
450
-			'description'       => __( 'Limit result set to items that don\'t have the specified coupon(s) assigned.', 'woocommerce' ),
449
+		$params['customer'] = array(
450
+			'description'       => __('Limit result set to items that don\'t have the specified coupon(s) assigned.', 'woocommerce'),
451 451
 			'type'              => 'string',
452 452
 			'enum'              => array(
453 453
 				'new',
@@ -455,8 +455,8 @@  discard block
 block discarded – undo
455 455
 			),
456 456
 			'validate_callback' => 'rest_validate_request_arg',
457 457
 		);
458
-		$params['refunds']          = array(
459
-			'description'       => __( 'Limit result set to specific types of refunds.', 'woocommerce' ),
458
+		$params['refunds'] = array(
459
+			'description'       => __('Limit result set to specific types of refunds.', 'woocommerce'),
460 460
 			'type'              => 'string',
461 461
 			'default'           => '',
462 462
 			'enum'              => array(
@@ -468,8 +468,8 @@  discard block
 block discarded – undo
468 468
 			),
469 469
 			'validate_callback' => 'rest_validate_request_arg',
470 470
 		);
471
-		$params['segmentby']        = array(
472
-			'description'       => __( 'Segment the response by additional constraint.', 'woocommerce' ),
471
+		$params['segmentby'] = array(
472
+			'description'       => __('Segment the response by additional constraint.', 'woocommerce'),
473 473
 			'type'              => 'string',
474 474
 			'enum'              => array(
475 475
 				'product',
Please login to merge, or discard this patch.