Code Duplication    Length = 9-9 lines in 3 locations

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

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