SecurityMiddlewarePass   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 3
dl 0
loc 19
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 11 2
1
<?php
2
namespace League\Tactician\Bundle\DependencyInjection\Compiler;
3
4
use League\Tactician\Bundle\Middleware\SecurityMiddleware;
5
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
6
use Symfony\Component\DependencyInjection\ContainerBuilder;
7
use Symfony\Component\DependencyInjection\Definition;
8
use Symfony\Component\DependencyInjection\Reference;
9
10
/**
11
 * This compiler pass registers security middleware if possible
12
 */
13
class SecurityMiddlewarePass implements CompilerPassInterface
14
{
15
    const SERVICE_ID = 'tactician.middleware.security';
16
17
    /**
18
     * {@inheritdoc}
19
     */
20 66
    public function process(ContainerBuilder $container)
21
    {
22 66
        if (false === $container->hasDefinition('security.authorization_checker')) {
23 48
            return;
24
        }
25
26 18
        $container->setDefinition(
27 18
            static::SERVICE_ID,
28 18
            new Definition(SecurityMiddleware::class, [ new Reference('security.authorization_checker') ])
29
        );
30 18
    }
31
}
32
33