Total Complexity | 6 |
Total Lines | 51 |
Duplicated Lines | 0 % |
Coverage | 69.23% |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
17 | class InvalidMiddlewareResolverHandlerException extends InvalidArgumentException |
||
18 | { |
||
19 | /** |
||
20 | * @param mixed $handler |
||
21 | * @return self |
||
22 | */ |
||
23 | 12 | public static function create($handler): self |
|
24 | { |
||
25 | 12 | return new self(sprintf( |
|
26 | 'Handler "%s" must be an instance or name of a class that implements `%s` or `%s`' |
||
27 | . ' interface as well as a PHP callable or array of such arguments.', |
||
28 | 12 | self::convertToString($handler), |
|
29 | MiddlewareInterface::class, |
||
30 | 12 | RequestHandlerInterface::class |
|
31 | )); |
||
32 | } |
||
33 | |||
34 | /** |
||
35 | * @param mixed $response |
||
36 | * @return self |
||
37 | */ |
||
38 | 6 | public static function forCallableMissingResponse($response): self |
|
39 | { |
||
40 | 6 | return new self(sprintf( |
|
41 | 'Callable handler must returned an instance of `Psr\Http\Message\ResponseInterface`; received "%s".', |
||
42 | 6 | self::convertToString($response) |
|
43 | )); |
||
44 | } |
||
45 | |||
46 | /** |
||
47 | * @param string $handler |
||
48 | * @return self |
||
49 | */ |
||
50 | public static function forStringNotConvertedToInstance(string $handler): self |
||
58 | )); |
||
59 | } |
||
60 | |||
61 | /** |
||
62 | * @param mixed $data |
||
63 | * @return string |
||
64 | */ |
||
65 | 18 | private static function convertToString($data): string |
|
68 | } |
||
69 | } |
||
70 |