Code Duplication    Length = 3-3 lines in 5 locations

includes/api/class-wc-rest-order-notes-controller.php 2 locations

@@ 252-254 (lines=3) @@
249
250
		$note = get_comment( $id );
251
252
		if ( empty( $id ) || empty( $note ) || intval( $note->comment_post_ID ) !== intval( $order->ID ) ) {
253
			return new WP_Error( 'woocommerce_rest_invalid_id', __( 'Invalid resource ID.', 'woocommerce' ), array( 'status' => 404 ) );
254
		}
255
256
		$order_note = $this->prepare_item_for_response( $note, $request );
257
		$response   = rest_ensure_response( $order_note );
@@ 285-287 (lines=3) @@
282
283
		$note = get_comment( $id );
284
285
		if ( empty( $id ) || empty( $note ) || intval( $note->comment_post_ID ) !== intval( $order->ID ) ) {
286
			return new WP_Error( 'woocommerce_rest_invalid_id', __( 'Invalid resource ID.', 'woocommerce' ), array( 'status' => 404 ) );
287
		}
288
289
		$request->set_param( 'context', 'edit' );
290
		$response = $this->prepare_item_for_response( $note, $request );

includes/api/class-wc-rest-product-reviews-controller.php 3 locations

@@ 234-236 (lines=3) @@
231
232
		$review = get_comment( $id );
233
234
		if ( empty( $id ) || empty( $review ) || intval( $review->comment_post_ID ) !== $product_id ) {
235
			return new WP_Error( 'woocommerce_rest_invalid_id', __( 'Invalid resource ID.', 'woocommerce' ), array( 'status' => 404 ) );
236
		}
237
238
		$delivery = $this->prepare_item_for_response( $review, $request );
239
		$response = rest_ensure_response( $delivery );
@@ 315-317 (lines=3) @@
312
313
		$review = get_comment( $product_review_id );
314
315
		if ( empty( $product_review_id ) || empty( $review ) || intval( $review->comment_post_ID ) !== $product_id ) {
316
			return new WP_Error( 'woocommerce_rest_product_review_invalid_id', __( 'Invalid resource ID.', 'woocommerce' ), array( 'status' => 404 ) );
317
		}
318
319
		$prepared_review = $this->prepare_item_for_database( $request );
320
@@ 359-361 (lines=3) @@
356
		$force = isset( $request['force'] ) ? (bool) $request['force'] : false;
357
358
		$product_review = get_comment( $product_review_id );
359
		if ( empty( $product_review_id ) || empty( $product_review->comment_ID ) || empty( $product_review->comment_post_ID ) ) {
360
			return new WP_Error( 'woocommerce_rest_product_review_invalid_id', __( 'Invalid product review ID.', 'woocommerce' ), array( 'status' => 404 ) );
361
		}
362
363
		/**
364
		 * Filter whether a product review is trashable.