FormatGuesserPass::process()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 7
nc 3
nop 1
1
<?php
2
3
namespace Knp\FriendlyContexts\DependencyInjection\Compiler;
4
5
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
6
use Symfony\Component\DependencyInjection\ContainerBuilder;
7
use Symfony\Component\DependencyInjection\Reference;
8
9
class FormatGuesserPass implements CompilerPassInterface
10
{
11
    public function process(ContainerBuilder $container)
12
    {
13
        $managerDefinition = $container->getDefinition('friendly.guesser.manager');
14
        foreach (array_keys($container->findTaggedServiceIds('friendly.format.guesser')) as $id) {
15
            $managerDefinition->addMethodCall('addGuesser', [ new Reference($id) ]);
16
            $guesserDefinition = $container->getDefinition($id);
17
            foreach (array_keys($container->findTaggedServiceIds(sprintf('%s.faker', $id))) as $id2) {
18
                $guesserDefinition->addMethodCall('addFaker', [ new Reference($id2) ]);
19
            }
20
        }
21
    }
22
}
23