Code Duplication    Length = 11-11 lines in 3 locations

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

@@ 134-144 (lines=11) @@
131
	 * @param  WP_REST_Request $request Full details about the request.
132
	 * @return WP_Error|boolean
133
	 */
134
	public function get_item_permissions_check( $request ) {
135
		if ( ! $this->get_taxonomy( $request ) ) {
136
			return new WP_Error( "woocommerce_rest_taxonomy_invalid", __( "Resource doesn't exist.", 'woocommerce' ), array( 'status' => 404 ) );
137
		}
138
139
		if ( ! wc_rest_check_manager_permissions( 'attributes', 'read' ) ) {
140
			return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot view this resource', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
141
		}
142
143
		return true;
144
	}
145
146
	/**
147
	 * Check if a given request has access to update a attribute.
@@ 152-162 (lines=11) @@
149
	 * @param  WP_REST_Request $request Full details about the request.
150
	 * @return WP_Error|boolean
151
	 */
152
	public function update_item_permissions_check( $request ) {
153
		if ( ! $this->get_taxonomy( $request ) ) {
154
			return new WP_Error( "woocommerce_rest_taxonomy_invalid", __( "Resource doesn't exist.", 'woocommerce' ), array( 'status' => 404 ) );
155
		}
156
157
		if ( ! wc_rest_check_manager_permissions( 'attributes', 'edit' ) ) {
158
			return new WP_Error( 'woocommerce_rest_cannot_update', __( 'Sorry, you cannot update resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
159
		}
160
161
		return true;
162
	}
163
164
	/**
165
	 * Check if a given request has access to delete a attribute.
@@ 170-180 (lines=11) @@
167
	 * @param  WP_REST_Request $request Full details about the request.
168
	 * @return WP_Error|boolean
169
	 */
170
	public function delete_item_permissions_check( $request ) {
171
		if ( ! $this->get_taxonomy( $request ) ) {
172
			return new WP_Error( "woocommerce_rest_taxonomy_invalid", __( "Resource doesn't exist.", 'woocommerce' ), array( 'status' => 404 ) );
173
		}
174
175
		if ( ! wc_rest_check_manager_permissions( 'attributes', 'delete' ) ) {
176
			return new WP_Error( 'woocommerce_rest_cannot_delete', __( 'Sorry, you cannot delete resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
177
		}
178
179
		return true;
180
	}
181
182
	/**
183
	 * Get all attributes.