Completed
Push — master ( 531aca...edc713 )
by Kamil
04:19
created

ContextRegistryPass   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 30
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A process() 0 11 2
1
<?php
2
3
/*
4
 * This file is part of the ContextServiceExtension package.
5
 *
6
 * (c) FriendsOfBehat
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace FriendsOfBehat\ContextServiceExtension\ServiceContainer\Scenario;
13
14
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
15
use Symfony\Component\DependencyInjection\ContainerBuilder;
16
use Symfony\Component\DependencyInjection\Definition;
17
18
/**
19
 * @internal
20
 */
21
final class ContextRegistryPass implements CompilerPassInterface
22
{
23
    /**
24
     * @var Definition
25
     */
26
    private $contextRegistryDefinition;
27
28
    /**
29
     * @param Definition $contextRegistryDefinition
30
     */
31
    public function __construct(Definition $contextRegistryDefinition)
32
    {
33
        $this->contextRegistryDefinition = $contextRegistryDefinition;
34
    }
35
36
    /**
37
     * {@inheritdoc}
38
     */
39
    public function process(ContainerBuilder $container)
40
    {
41
        $taggedServices = $container->findTaggedServiceIds('fob.context_service');
42
43
        foreach ($taggedServices as $id => $tags) {
44
            $this->contextRegistryDefinition->addMethodCall(
45
                'add',
46
                [$id, $container->findDefinition($id)->getClass()]
47
            );
48
        }
49
    }
50
}
51