Completed
Branch BUG/chicken-is-a-required-ques... (f96ad9)
by
unknown
42:30 queued 28:14
created

DuplicateCollectionIdentifierException   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 25
loc 25
rs 10
c 1
b 0
f 0
wmc 2
lcom 0
cbo 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 13 13 2

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace EventEspresso\core\services\collections;
4
5
use Exception;
6
use OutOfRangeException;
7
8
/**
9
 * Class DuplicateCollectionIdentifierException
10
 * Thrown when the supplied identifier already exists in a Collection while trying to add a new item
11
 *
12
 * @package EventEspresso\core\services\collections
13
 * @author  Brent Christensen
14
 * @since   $VID:$
15
 */
16 View Code Duplication
class DuplicateCollectionIdentifierException extends OutOfRangeException
17
{
18
19
    /**
20
     * DuplicateCollectionIdentifierException constructor.
21
     *
22
     * @param                $identifier
23
     * @param string         $message
24
     * @param int            $code
25
     * @param Exception|null $previous
26
     */
27
    public function __construct($identifier, $message = '', $code = 0, Exception $previous = null)
28
    {
29
        if (empty($message)) {
30
            $message = sprintf(
31
                __(
32
                    'The supplied identifier "%1$s" already exists within this collection.',
33
                    'event_espresso'
34
                ),
35
                $identifier
36
            );
37
        }
38
        parent::__construct($message, $code, $previous);
39
    }
40
}
41