Completed
Branch FET-9795-new-interfaces (ea072c)
by
unknown
19:19
created

InvalidEntityException   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 26
loc 26
rs 10
c 0
b 0
f 0
wmc 3
lcom 0
cbo 0

1 Method

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

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
namespace EventEspresso\core\exceptions;
3
4
if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
5
	exit( 'No direct script access allowed' );
6
}
7
/**
8
 * Class InvalidEntityException
9
 * thrown when an entity is not of the expected instance
10
 *
11
 * @package       Event Espresso
12
 * @author        Brent Christensen
13
 * @since         4.9.0
14
 */
15 View Code Duplication
 class InvalidEntityException extends \InvalidArgumentException {
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
16
17
	 /**
18
	  * InvalidInterfaceException constructor.
19
	  *
20
	  * @param string     $actual   classname of what we got
21
	  * @param string     $expected classname of the entity we wanted
22
	  * @param string     $message
23
	  * @param int        $code
24
	  * @param \Exception $previous
25
	  */
26
	 public function __construct( $actual, $expected, $message = '', $code = 0, \Exception $previous = null ) {
27
		 if ( empty( $message ) ) {
28
			 $message = sprintf(
29
				 __(
30
					 'The supplied entity is an instance of "%1$s", but an instance of "%2$s" was expected.',
31
					 'event_espresso'
32
				 ),
33
				 is_object($actual) ? get_class($actual) : gettype($actual),
34
				 $expected
35
			 );
36
		 }
37
		 parent::__construct( $message, $code, $previous );
38
	 }
39
40
 }
41
// End of file InvalidEntityException.php
42
// Location: /InvalidEntityException.php