Code Duplication    Length = 9-9 lines in 3 locations

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

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