Code Duplication    Length = 7-13 lines in 3 locations

core/db_models/EEM_Base.model.php 2 locations

@@ 2897-2903 (lines=7) @@
2894
     */
2895
    public function get_one_conflicting($obj_or_fields_array, $include_primary_key = true)
2896
    {
2897
        if ($obj_or_fields_array instanceof EE_Base_Class) {
2898
            $fields_n_values = $obj_or_fields_array->model_field_array();
2899
        } elseif (is_array($obj_or_fields_array)) {
2900
            $fields_n_values = $obj_or_fields_array;
2901
        } else {
2902
            throw new EE_Error(
2903
                sprintf(
2904
                    __(
2905
                        "%s get_all_conflicting should be called with a model object or an array of field names and values, you provided %d",
2906
                        "event_espresso"
@@ 5759-5765 (lines=7) @@
5756
     */
5757
    public function get_all_copies($model_object_or_attributes_array, $query_params = array())
5758
    {
5759
        if ($model_object_or_attributes_array instanceof EE_Base_Class) {
5760
            $attributes_array = $model_object_or_attributes_array->model_field_array();
5761
        } elseif (is_array($model_object_or_attributes_array)) {
5762
            $attributes_array = $model_object_or_attributes_array;
5763
        } else {
5764
            throw new EE_Error(sprintf(__("get_all_copies should be provided with either a model object or an array of field-value-pairs, but was given %s",
5765
                "event_espresso"), $model_object_or_attributes_array));
5766
        }
5767
        //even copies obviously won't have the same ID, so remove the primary key
5768
        //from the WHERE conditions for finding copies (if there is a primary key, of course)

core/db_classes/EE_Base_Class.class.php 1 location

@@ 2072-2084 (lines=13) @@
2069
            if ($otherObject instanceof EE_Base_Class) {
2070
                $otherObject->clear_cache($model->get_this_model_name(), $this);
2071
            }
2072
        } else {
2073
            //this thing doesn't exist in the DB,  so just cache it
2074
            if ( ! $otherObjectModelObjectOrID instanceof EE_Base_Class) {
2075
                throw new EE_Error(sprintf(
2076
                    __('Before a model object is saved to the database, calls to _add_relation_to must be passed an actual object, not just an ID. You provided %s as the model object to a %s',
2077
                        'event_espresso'),
2078
                    $otherObjectModelObjectOrID,
2079
                    get_class($this)
2080
                ));
2081
            } else {
2082
                $otherObject = $otherObjectModelObjectOrID;
2083
            }
2084
            $this->cache($relationName, $otherObjectModelObjectOrID, $cache_id);
2085
        }
2086
        if ($otherObject instanceof EE_Base_Class) {
2087
            //fix the reciprocal relation too