Code Duplication    Length = 8-15 lines in 4 locations

core/db_models/EEM_Base.model.php 4 locations

@@ 4253-4267 (lines=15) @@
4250
            $cleaned_value = $this->_construct_between_value($value, $field_obj);
4251
            return $operator . SP . $cleaned_value;
4252
        }
4253
        if (in_array($operator, $this->_null_style_operators)) {
4254
            if ($value !== null) {
4255
                throw new EE_Error(
4256
                    sprintf(
4257
                        __(
4258
                            "You attempted to give a value  (%s) while using a NULL-style operator (%s). That isn't valid",
4259
                            "event_espresso"
4260
                        ),
4261
                        $value,
4262
                        $operator
4263
                    )
4264
                );
4265
            }
4266
            return $operator;
4267
        }
4268
        if ($operator === 'LIKE' && ! is_array($value)) {
4269
            //if the operator is 'LIKE', we want to allow percent signs (%) and not
4270
            //remove other junk. So just treat it as a string.
@@ 4276-4287 (lines=12) @@
4273
        if (! in_array($operator, $this->_in_style_operators) && ! is_array($value)) {
4274
            return $operator . SP . $this->_wpdb_prepare_using_field($value, $field_obj);
4275
        }
4276
        if (in_array($operator, $this->_in_style_operators) && ! is_array($value)) {
4277
            throw new EE_Error(
4278
                sprintf(
4279
                    __(
4280
                        "Operator '%s' must be used with an array of values, eg 'Registration.REG_ID' => array('%s',array(1,2,3))",
4281
                        'event_espresso'
4282
                    ),
4283
                    $operator,
4284
                    $operator
4285
                )
4286
            );
4287
        }
4288
        if (! in_array($operator, $this->_in_style_operators) && is_array($value)) {
4289
            throw new EE_Error(
4290
                sprintf(
@@ 4288-4299 (lines=12) @@
4285
                )
4286
            );
4287
        }
4288
        if (! in_array($operator, $this->_in_style_operators) && is_array($value)) {
4289
            throw new EE_Error(
4290
                sprintf(
4291
                    __(
4292
                        "Operator '%s' must be used with a single value, not an array. Eg 'Registration.REG_ID => array('%s',23))",
4293
                        'event_espresso'
4294
                    ),
4295
                    $operator,
4296
                    $operator
4297
                )
4298
            );
4299
        }
4300
        throw new EE_Error(
4301
            sprintf(
4302
                __(
@@ 4388-4395 (lines=8) @@
4385
            return $wpdb->prepare($field_obj->get_wpdb_data_type(),
4386
                $this->_prepare_value_for_use_in_db($value, $field_obj));
4387
        } //$field_obj should really just be a data type
4388
        if (! in_array($field_obj, $this->_valid_wpdb_data_types)) {
4389
            throw new EE_Error(
4390
                sprintf(
4391
                    __("%s is not a valid wpdb datatype. Valid ones are %s", "event_espresso"),
4392
                    $field_obj, implode(",", $this->_valid_wpdb_data_types)
4393
                )
4394
            );
4395
        }
4396
        return $wpdb->prepare($field_obj, $value);
4397
    }
4398