MiddlewareNotConfigured   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 19
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A forMiddleware() 0 8 1
A becauseGroupIsEmpty() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Kafkiansky\SymfonyMiddleware\Middleware;
6
7
use Psr\Http\Server\MiddlewareInterface;
8
9
final class MiddlewareNotConfigured extends \Exception
10
{
11
    public static function forMiddleware(string $middlewareNameOrGroup): MiddlewareNotConfigured
12
    {
13
        return new MiddlewareNotConfigured(
14
            vsprintf(
15
                'The middleware or group "%s" was not configured. Make sure it implements the "%s" interface or group is defined.',
16
                [
17
                    $middlewareNameOrGroup,
18
                    MiddlewareInterface::class,
19
                ]
20
            )
21
        );
22
    }
23
24
    public static function becauseGroupIsEmpty(string $groupName): MiddlewareNotConfigured
25
    {
26
        return new MiddlewareNotConfigured(
27
            sprintf('Middlewares groups cannot empty, but the group "%s" is.', $groupName)
28
        );
29
    }
30
}
31