Completed
Branch BUG-9871-email-validation (e62b1a)
by
unknown
350:41 queued 333:27
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  
A __construct() 22 22 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\services\commands\middleware;
3
4
use EventEspresso\core\exceptions\InvalidDataTypeException;
5
6
if ( ! defined('EVENT_ESPRESSO_VERSION')) {
7
    exit('No direct script access allowed');
8
}
9
10
11
12
/**
13
 * Class InvalidCommandBusMiddlewareException
14
 *
15
 * thrown when an invalid object is encountered when processing CommandBus middleware
16
 *
17
 * @package       Event Espresso
18
 * @author        Brent Christensen
19
 * @since         4.9.1
20
 *
21
 */
22 View Code Duplication
class InvalidCommandBusMiddlewareException extends InvalidDataTypeException
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...
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