Code Duplication    Length = 9-14 lines in 7 locations

core/db_classes/EE_Message_Template_Group.class.php 1 location

@@ 485-498 (lines=14) @@
482
    public function validate_context($context)
483
    {
484
        $contexts = $this->contexts_config();
485
        if (! isset($contexts[$context])) {
486
            throw new InvalidIdentifierException(
487
                '',
488
                '',
489
                sprintf(
490
                    esc_html__(
491
                        'An invalid string identifying a context was provided.  "%1$s" was received, and one of "%2$s" was expected.',
492
                        'event_espresso'
493
                    ),
494
                    $context,
495
                    implode(',', array_keys($contexts))
496
                )
497
            );
498
        }
499
    }
500
}
501

core/db_models/fields/EE_Model_Field_Base.php 2 locations

@@ 611-619 (lines=9) @@
608
            return;
609
        }
610
611
        if (! isset($allowable_types[$type])) {
612
            throw new InvalidArgumentException(
613
                sprintf(
614
                    esc_html__('The incoming argument (%1$s) must be one of the allowable types: %2$s', 'event_espresso'),
615
                    $type,
616
                    implode(',', array_flip($allowable_types))
617
                )
618
            );
619
        }
620
    }
621
622
@@ 653-661 (lines=9) @@
650
            )
651
        );
652
653
        if (! isset($allowable_formats[$format])) {
654
            throw new InvalidArgumentException(
655
                sprintf(
656
                    esc_html__('The incoming argument (%1$s) must be one of the allowable formats: %2$s', 'event_espresso'),
657
                    $format,
658
                    implode(',', array_flip($allowable_formats))
659
                )
660
            );
661
        }
662
    }
663
}

core/domain/values/Version.php 1 location

@@ 221-232 (lines=12) @@
218
            Version::RELEASE_TYPE_DECAF,
219
            Version::RELEASE_TYPE_PROD,
220
        );
221
        if (! in_array($release, $valid_release_types, true)) {
222
            throw new InvalidArgumentException(
223
                sprintf(
224
                    esc_html__(
225
                        '"%1$s" is not a valid release type. Please use one of the following values: %2$s',
226
                        'event_espresso'
227
                    ),
228
                    $release,
229
                    implode(', ', $valid_release_types)
230
                )
231
            );
232
        }
233
        $this->release = $release;
234
    }
235

core/domain/values/model/CustomSelects.php 2 locations

@@ 208-221 (lines=14) @@
205
        $data_type = $this->type === self::TYPE_COMPLEX ? $select_parts[1] : '';
206
        $data_type = $this->type === self::TYPE_STRUCTURED ? $select_parts[2] : $data_type;
207
208
        if (! in_array($data_type, $valid_data_types, true)) {
209
            throw new InvalidArgumentException(
210
                sprintf(
211
                    esc_html__(
212
                        'Datatype %1$s (for selection "%2$s" and alias "%3$s") is not a valid wpdb datatype (eg %%s)',
213
                        'event_espresso'
214
                    ),
215
                    $data_type,
216
                    $select_parts[0],
217
                    $alias,
218
                    implode(', ', $valid_data_types)
219
                )
220
            );
221
        }
222
    }
223
224
@@ 251-263 (lines=13) @@
248
    {
249
        $operator = strtoupper($select_parts[1]);
250
        //validate operator
251
        if (! in_array($operator, $this->valid_operators, true)) {
252
            throw new InvalidArgumentException(
253
                sprintf(
254
                    esc_html__(
255
                        'An invalid operator has been provided (%1$s) for the column %2$s.  Valid operators must be one of the following: %3$s.',
256
                        'event_espresso'
257
                    ),
258
                    $operator,
259
                    $alias,
260
                    implode(', ', $this->valid_operators)
261
                )
262
            );
263
        }
264
        return $operator . '(' . $select_parts[0] . ') AS ' . $alias;
265
    }
266

core/db_classes/EE_Base_Class.class.php 1 location

@@ 151-163 (lines=13) @@
148
        $fieldValues = is_array($fieldValues) ? $fieldValues : array($fieldValues);
149
        // verify client code has not passed any invalid field names
150
        foreach ($fieldValues as $field_name => $field_value) {
151
            if (! isset($model_fields[ $field_name ])) {
152
                throw new EE_Error(
153
                    sprintf(
154
                        esc_html__(
155
                            'Invalid field (%s) passed to constructor of %s. Allowed fields are :%s',
156
                            'event_espresso'
157
                        ),
158
                        $field_name,
159
                        get_class($this),
160
                        implode(', ', array_keys($model_fields))
161
                    )
162
                );
163
            }
164
        }
165
        $this->_timezone = EEH_DTT_Helper::get_valid_timezone_string($timezone);
166
        if (! empty($date_formats) && is_array($date_formats)) {