Code Duplication    Length = 11-12 lines in 3 locations

includes/api/class-wc-rest-orders-controller.php 1 location

@@ 882-892 (lines=11) @@
879
	 * @param array $item Item provided in the request body.
880
	 * @return bool True if the item resource ID is null, false otherwise.
881
	 */
882
	protected function item_is_null( $item ) {
883
		$keys = array( 'product_id', 'method_id', 'title', 'code' );
884
885
		foreach ( $keys as $key ) {
886
			if ( array_key_exists( $key, $item ) && is_null( $item[ $key ] ) ) {
887
				return true;
888
			}
889
		}
890
891
		return false;
892
	}
893
894
	/**
895
	 * Update order.

includes/api/legacy/v2/class-wc-api-orders.php 1 location

@@ 801-812 (lines=12) @@
798
	 * @param array $item item provided in the request body
799
	 * @return bool true if the item resource ID is null, false otherwise
800
	 */
801
	protected function item_is_null( $item ) {
802
803
		$keys = array( 'product_id', 'method_id', 'title', 'code' );
804
805
		foreach ( $keys as $key ) {
806
			if ( array_key_exists( $key, $item ) && is_null( $item[ $key ] ) ) {
807
				return true;
808
			}
809
		}
810
811
		return false;
812
	}
813
814
	/**
815
	 * Wrapper method to create/update order items

includes/api/legacy/v3/class-wc-api-orders.php 1 location

@@ 844-855 (lines=12) @@
841
	 * @param array $item item provided in the request body
842
	 * @return bool true if the item resource ID is null, false otherwise
843
	 */
844
	protected function item_is_null( $item ) {
845
846
		$keys = array( 'product_id', 'method_id', 'title', 'code' );
847
848
		foreach ( $keys as $key ) {
849
			if ( array_key_exists( $key, $item ) && is_null( $item[ $key ] ) ) {
850
				return true;
851
			}
852
		}
853
854
		return false;
855
	}
856
857
	/**
858
	 * Wrapper method to create/update order items