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

__construct()   B

Complexity

Conditions 3
Paths 4

Size

Total Lines 24
Code Lines 17

Duplication

Lines 24
Ratio 100 %

Importance

Changes 0
Metric Value
cc 3
eloc 17
nc 4
nop 4
dl 24
loc 24
rs 8.9713
c 0
b 0
f 0
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