Code Duplication    Length = 9-9 lines in 3 locations

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

@@ 153-161 (lines=9) @@
150
	 * @param  WP_REST_Request $request Full details about the request.
151
	 * @return WP_Error|boolean
152
	 */
153
	public function get_item_permissions_check( $request ) {
154
		$id = (int) $request['id'];
155
156
		if ( ! wc_rest_check_user_permissions( 'read', $id ) ) {
157
			return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot view this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
158
		}
159
160
		return true;
161
	}
162
163
	/**
164
	 * Check if a given request has access update a customer.
@@ 169-177 (lines=9) @@
166
	 * @param  WP_REST_Request $request Full details about the request.
167
	 * @return boolean
168
	 */
169
	public function update_item_permissions_check( $request ) {
170
		$id = (int) $request['id'];
171
172
		if ( ! wc_rest_check_user_permissions( 'edit', $id ) ) {
173
			return new WP_Error( 'woocommerce_rest_cannot_edit', __( 'Sorry, you are not allowed to edit this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
174
		}
175
176
		return true;
177
	}
178
179
	/**
180
	 * Check if a given request has access delete a customer.
@@ 185-193 (lines=9) @@
182
	 * @param  WP_REST_Request $request Full details about the request.
183
	 * @return boolean
184
	 */
185
	public function delete_item_permissions_check( $request ) {
186
		$id = (int) $request['id'];
187
188
		if ( ! wc_rest_check_user_permissions( 'delete', $id ) ) {
189
			return new WP_Error( 'woocommerce_rest_cannot_delete', __( 'Sorry, you are not allowed to delete this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
190
		}
191
192
		return true;
193
	}
194
195
	/**
196
	 * Check if a given request has access batch create, update and delete items.