MiddlewareNotConfigured::forMiddleware()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 1
dl 0
loc 8
rs 10
c 0
b 0
f 0
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