Code Duplication    Length = 3-3 lines in 9 locations

includes/abstracts/abstract-wc-rest-controller.php 1 location

@@ 95-97 (lines=3) @@
92
			$total += count( $items['delete'] );
93
		}
94
95
		if ( $total > $limit ) {
96
			return new WP_Error( 'woocommerce_rest_request_entity_too_large', sprintf( __( 'Unable to accept more than %s items for this request.', 'woocommerce' ), $limit ), array( 'status' => 413 ) );
97
		}
98
99
		return true;
100
	}

includes/abstracts/abstract-wc-rest-shipping-zones-controller.php 1 location

@@ 48-50 (lines=3) @@
45
	protected function get_zone( $zone_id ) {
46
		$zone = WC_Shipping_Zones::get_zone_by( 'zone_id', $zone_id );
47
48
		if ( false === $zone ) {
49
			return new WP_Error( 'woocommerce_rest_shipping_zone_invalid', __( "Resource doesn't exist.", 'woocommerce' ), array( 'status' => 404 ) );
50
		}
51
52
		return $zone;
53
	}

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

@@ 362-364 (lines=3) @@
359
		);
360
361
		// Checks for errors.
362
		if ( false === $update ) {
363
			return new WP_Error( 'woocommerce_rest_cannot_edit', __( 'Could not edit the attribute.', 'woocommerce' ), array( 'status' => 400 ) );
364
		}
365
366
		$attribute = $this->get_attribute( $id );
367
@@ 424-426 (lines=3) @@
421
			array( '%d' )
422
		);
423
424
		if ( false === $deleted ) {
425
			return new WP_Error( 'woocommerce_rest_cannot_delete', __( 'The resource cannot be deleted.', 'woocommerce' ), array( 'status' => 500 ) );
426
		}
427
428
		$taxonomy = wc_attribute_taxonomy_name( $attribute->attribute_name );
429

includes/api/class-wc-rest-shipping-zone-methods-controller.php 4 locations

@@ 95-97 (lines=3) @@
92
			}
93
		}
94
95
		if ( false === $method ) {
96
			return new WP_Error( 'woocommerce_rest_shipping_zone_method_invalid', __( "Resource doesn't exist.", 'woocommerce' ), array( 'status' => 404 ) );
97
		}
98
99
		$data = $this->prepare_item_for_response( $method, $request );
100
@@ 153-155 (lines=3) @@
150
			}
151
		}
152
153
		if ( false === $method ) {
154
			return new WP_Error( 'woocommerce_rest_shipping_zone_not_created', __( 'Resource cannot be created.', 'woocommerce' ), array( 'status' => 500 ) );
155
		}
156
157
		$method = $this->update_fields( $instance_id, $method, $request );
158
@@ 190-192 (lines=3) @@
187
			}
188
		}
189
190
		if ( false === $method ) {
191
			return new WP_Error( 'woocommerce_rest_shipping_zone_method_invalid', __( "Resource doesn't exist.", 'woocommerce' ), array( 'status' => 404 ) );
192
		}
193
194
		$method = $this->update_fields( $instance_id, $method, $request );
195
		$request->set_param( 'context', 'view' );
@@ 242-244 (lines=3) @@
239
			}
240
		}
241
242
		if ( false === $method ) {
243
			return new WP_Error( 'woocommerce_rest_shipping_zone_method_invalid', __( "Resource doesn't exist.", 'woocommerce' ), array( 'status' => 404 ) );
244
		}
245
246
		$method = $this->update_fields( $instance_id, $method, $request );
247

includes/wc-rest-functions.php 1 location

@@ 105-107 (lines=3) @@
102
		// Recheck filetype
103
		$wp_filetype = wp_check_filetype( $file_name, wc_rest_allowed_image_mime_types() );
104
105
		if ( ! $wp_filetype['type'] ) {
106
			return new WP_Error( 'woocommerce_rest_invalid_image_type', __( 'Invalid image type.', 'woocommerce' ), array( 'status' => 400 ) );
107
		}
108
	}
109
110
	// Upload the file.