MiddlewareCompilerPass   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 4
dl 0
loc 22
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 13 2
1
<?php
2
3
namespace BrainExe\Core\DependencyInjection\CompilerPass;
4
5
use BrainExe\Core\Annotations\CompilerPass;
6
use BrainExe\Core\Application\AppKernel;
7
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
8
use Symfony\Component\DependencyInjection\ContainerBuilder;
9
use Symfony\Component\DependencyInjection\Reference;
10
11
/**
12
 * @CompilerPass
13
 */
14
class MiddlewareCompilerPass implements CompilerPassInterface
15
{
16
17
    const TAG = 'middleware';
18
19
    /**
20
     * {@inheritdoc}
21
     */
22 2
    public function process(ContainerBuilder $container)
23
    {
24 2
        $appKernel   = $container->findDefinition(AppKernel::class);
25 2
        $middlewares = $container->getParameter('application.middlewares');
26
27 2
        $references  = [];
28 2
        foreach ($middlewares as $serviceId) {
29 1
            $references[] = new Reference($serviceId);
30
        }
31
32 2
        $appKernel->addArgument($references);
33 2
        $container->getParameterBag()->remove('application.middlewares');
34 2
    }
35
}
36