Code Duplication    Length = 26-36 lines in 3 locations

core/exceptions/InvalidEntityException.php 1 location

@@ 15-40 (lines=26) @@
12
 * @author        Brent Christensen
13
 * @since         4.9.0
14
 */
15
 class InvalidEntityException extends \InvalidArgumentException {
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

core/exceptions/UnexpectedEntityException.php 1 location

@@ 18-43 (lines=26) @@
15
 * @author        Brent Christensen
16
 * @since         $VID:$
17
 */
18
class UnexpectedEntityException extends \UnexpectedValueException {
19
20
	/**
21
	 * UnexpectedEntityException constructor
22
	 *
23
	 * @param mixed      $entity the actual object or variable that was received
24
	 * @param string     $expected_class classname of the entity we wanted
25
	 * @param string     $message
26
	 * @param int        $code
27
	 * @param \Exception $previous
28
	 */
29
	public function __construct( $entity, $expected_class, $message = '', $code = 0, \Exception $previous = null ) {
30
		if ( empty( $message ) ) {
31
			$message = sprintf(
32
				__(
33
					'The retrieved entity is an instance of "%1$s", but an instance of "%2$s" was expected.',
34
					'event_espresso'
35
				),
36
				is_object( $entity ) ? get_class( $entity ) : gettype( $entity ),
37
				$expected_class
38
			);
39
		}
40
		parent::__construct( $message, $code, $previous );
41
	}
42
43
}
44
// End of file UnexpectedEntityException.php
45
// Location: /UnexpectedEntityException.php

core/services/commands/middleware/InvalidCommandBusMiddlewareException.php 1 location

@@ 22-57 (lines=36) @@
19
 * @since         4.9.1
20
 *
21
 */
22
class InvalidCommandBusMiddlewareException extends InvalidDataTypeException
23
{
24
25
26
    /**
27
     * @access public
28
     * @param  mixed     $command_bus_middleware_object
29
     * @param  string    $message
30
     * @param int        $code
31
     * @param \Exception $previous
32
     */
33
    public function __construct($command_bus_middleware_object, $message = '', $code = 0, \Exception $previous = null)
34
    {
35
        $command_bus_middleware = is_object($command_bus_middleware_object)
36
            ? get_class($command_bus_middleware_object)
37
            : gettype($command_bus_middleware_object);
38
39
        if (empty($message)) {
40
            $message = sprintf(
41
                __('The supplied Command Bus Middleware "%1$s" does not have a valid name. It should be in the following format: "{CommandName}Handler" ',
42
                    'event_espresso'),
43
                $command_bus_middleware
44
            );
45
        }
46
        parent::__construct(
47
            '$command_bus_middleware',
48
            $command_bus_middleware,
49
            'CommandBusMiddlewareInterface',
50
            $message,
51
            $code,
52
            $previous
53
        );
54
    }
55
56
57
}
58
// End of file InvalidCommandBusMiddlewareException.php
59
// Location: /InvalidCommandBusMiddlewareException.php