Completed
Branch FET/asset-manager (433489)
by
unknown
32:42 queued 18:11
created

InvalidCommandBusMiddlewareException   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
B __construct() 24 24 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
3
namespace EventEspresso\core\services\commands\middleware;
4
5
use EventEspresso\core\exceptions\InvalidDataTypeException;
6
7
/**
8
 * Class InvalidCommandBusMiddlewareException
9
 * thrown when an invalid object is encountered when processing CommandBus middleware
10
 *
11
 * @package       Event Espresso
12
 * @author        Brent Christensen
13
 * @since         4.9.1
14
 */
15 View Code Duplication
class InvalidCommandBusMiddlewareException extends InvalidDataTypeException
16
{
17
18
19
    /**
20
     * @access public
21
     * @param  mixed     $command_bus_middleware_object
22
     * @param  string    $message
23
     * @param int        $code
24
     * @param \Exception $previous
25
     */
26
    public function __construct($command_bus_middleware_object, $message = '', $code = 0, \Exception $previous = null)
27
    {
28
        $command_bus_middleware = is_object($command_bus_middleware_object)
29
            ? get_class($command_bus_middleware_object)
30
            : gettype($command_bus_middleware_object);
31
32
        if (empty($message)) {
33
            $message = sprintf(
34
                __(
35
                    'The supplied Command Bus Middleware "%1$s" does not have a valid name. It should be in the following format: "{CommandName}Handler" ',
36
                    'event_espresso'
37
                ),
38
                $command_bus_middleware
39
            );
40
        }
41
        parent::__construct(
42
            '$command_bus_middleware',
43
            $command_bus_middleware,
44
            'CommandBusMiddlewareInterface',
45
            $message,
46
            $code,
47
            $previous
48
        );
49
    }
50
}
51