TidyMiddlewareFactory   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 10
dl 0
loc 18
ccs 10
cts 10
cp 1
rs 10
c 2
b 0
f 0
wmc 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 16 4
1
<?php
2
declare(strict_types=1);
3
4
namespace Ctw\Middleware\TidyMiddleware;
5
6
use Psr\Container\ContainerInterface;
7
8
class TidyMiddlewareFactory
9
{
10 8
    public function __invoke(ContainerInterface $container): TidyMiddleware
11
    {
12 8
        $config = [];
13 8
        if ($container->has('config')) {
14 8
            $config = $container->get('config');
15 8
            assert(is_array($config));
16 8
            $config = $config[TidyMiddleware::class] ?? [];
17
        }
18
19 8
        $middleware = new TidyMiddleware();
20
21 8
        if ((is_countable($config) ? count($config) : 0) > 0) {
22 8
            $middleware->setConfig($config);
23
        }
24
25 8
        return $middleware;
26
    }
27
}
28