Code Duplication    Length = 13-13 lines in 2 locations

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

@@ 387-399 (lines=13) @@
384
	 * @param WP_REST_Request $request Full details about the request.
385
	 * @return WP_Error|WP_REST_Response
386
	 */
387
	public function get_item( $request ) {
388
		$id      = (int) $request['id'];
389
		$tax_obj = WC_Tax::_get_tax_rate( $id, OBJECT );
390
391
		if ( empty( $id ) || empty( $tax_obj ) ) {
392
			return new WP_Error( 'woocommerce_rest_invalid_id', __( 'Invalid resource ID.', 'woocommerce' ), array( 'status' => 404 ) );
393
		}
394
395
		$tax      = $this->prepare_item_for_response( $tax_obj, $request );
396
		$response = rest_ensure_response( $tax );
397
398
		return $response;
399
	}
400
401
	/**
402
	 * Update a single tax.

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

@@ 355-367 (lines=13) @@
352
	 * @param WP_REST_Request $request Full details about the request.
353
	 * @return WP_Error|WP_REST_Response
354
	 */
355
	public function get_item( $request ) {
356
		$id        = (int) $request['id'];
357
		$user_data = get_userdata( $id );
358
359
		if ( empty( $id ) || empty( $user_data->ID ) ) {
360
			return new WP_Error( 'woocommerce_rest_invalid_id', __( 'Invalid resource ID.', 'woocommerce' ), array( 'status' => 404 ) );
361
		}
362
363
		$customer = $this->prepare_item_for_response( $user_data, $request );
364
		$response = rest_ensure_response( $customer );
365
366
		return $response;
367
	}
368
369
	/**
370
	 * Update a single user.