InvalidMiddlewareException   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 0
dl 0
loc 17
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A forMiddleware() 0 9 2
1
<?php
2
3
namespace League\Tactician\Exception;
4
5
use InvalidArgumentException;
6
7
/**
8
 * Thrown when the CommandBus was instantiated with an invalid middleware object
9
 */
10
class InvalidMiddlewareException extends InvalidArgumentException implements Exception
11
{
12
    /**
13
     * @param $middleware
14
     *
15
     * @return InvalidMiddlewareException
16
     */
17 1
    public static function forMiddleware($middleware): InvalidMiddlewareException
18
    {
19 1
        $name = is_object($middleware) ? get_class($middleware) : gettype($middleware);
20 1
        $message = sprintf(
21 1
            'Cannot add "%s" to middleware chain as it does not implement the Middleware interface.',
22 1
            $name
23
        );
24 1
        return new static($message);
25
    }
26
}
27