Code Duplication    Length = 3-5 lines in 2 locations

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

@@ 438-442 (lines=5) @@
435
			return new WP_Error( 'woocommerce_rest_invalid_id', __( 'Invalid resource id.', 'woocommerce' ), array( 'status' => 400 ) );
436
		}
437
438
		if ( ! empty( $reassign ) ) {
439
			if ( $reassign === $id || ! get_userdata( $reassign ) ) {
440
				return new WP_Error( 'woocommerce_rest_customer_invalid_reassign', __( 'Invalid resource id for reassignment.', 'woocommerce' ), array( 'status' => 400 ) );
441
			}
442
		}
443
444
		$request->set_param( 'context', 'edit' );
445
		$response = $this->prepare_item_for_response( $customer, $request );

includes/wc-rest-functions.php 1 location

@@ 61-63 (lines=3) @@
58
	$parsed_url  = @parse_url( $image_url );
59
60
	// Check parsed URL.
61
	if ( ! $parsed_url || ! is_array( $parsed_url ) ) {
62
		return new WP_Error( 'woocommerce_rest_invalid_image_url', sprintf( __( 'Invalid URL %s.', 'woocommerce' ), $image_url ), array( 'status' => 400 ) );
63
	}
64
65
	// Ensure url is valid.
66
	$image_url = esc_url_raw( $image_url );