Completed
Branch GDPR/erasure (847b68)
by
unknown
40:32 queued 27:22
created

InvalidCollectionIdentifierException   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 14 14 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 OutOfBoundsException;
7
8
/**
9
 * Class InvalidCollectionIdentifierException
10
 * Thrown when the supplied identifier doesn't exist in a Collection when trying to retrieve an item
11
 *
12
 * @package EventEspresso\core\services\collections
13
 * @author  Brent Christensen
14
 * @since   $VID:$
15
 */
16 View Code Duplication
class InvalidCollectionIdentifierException extends OutOfBoundsException
17
{
18
19
    /**
20
     * InvalidCollectionIdentifierException 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" does not exist within this collection. 
33
                    You may need to delay adding this asset until the required dependency has been added.',
34
                    'event_espresso'
35
                ),
36
                $identifier
37
            );
38
        }
39
        parent::__construct($message, $code, $previous);
40
    }
41
}
42