Code Duplication    Length = 6-6 lines in 2 locations

includes/wpinv-item-functions.php 2 locations

@@ 839-844 (lines=6) @@
836
function wpinv_update_item( $args = array(), $wp_error = false ) {
837
    $item = !empty( $args['ID'] ) ? new WPInv_Item( $args['ID'] ) : NULL;
838
839
    if ( empty( $item ) || !( !empty( $item->post_type ) && $item->post_type == 'wpi_item' ) ) {
840
        if ( $wp_error ) {
841
            return new WP_Error( 'wpinv_invalid_item', __( 'Invalid item.', 'invoicing' ) );
842
        }
843
        return 0;
844
    }
845
    
846
    if ( !empty( $args['custom_id'] ) ) {
847
        $item_exists = wpinv_get_item_by( 'custom_id', $args['custom_id'], ( !empty( $args['type'] ) ? $args['type'] : $item->type ) );
@@ 849-854 (lines=6) @@
846
    if ( !empty( $args['custom_id'] ) ) {
847
        $item_exists = wpinv_get_item_by( 'custom_id', $args['custom_id'], ( !empty( $args['type'] ) ? $args['type'] : $item->type ) );
848
        
849
        if ( !empty( $item_exists ) && $item_exists->ID != $args['ID'] ) {
850
            if ( $wp_error ) {
851
                return new WP_Error( 'wpinv_invalid_custom_id', __( 'Item with custom id already exists.', 'invoicing' ) );
852
            }
853
            return 0;
854
        }
855
    }
856
857
    $meta_fields = array(