Code Duplication    Length = 9-9 lines in 3 locations

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

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