IndexPass::process()   A
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 15

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 4.0218

Importance

Changes 0
Metric Value
dl 0
loc 15
ccs 8
cts 9
cp 0.8889
rs 9.7666
c 0
b 0
f 0
cc 4
nc 4
nop 1
crap 4.0218
1
<?php
2
3
/*
4
 * This file is part of the FOSElasticaBundle package.
5
 *
6
 * (c) FriendsOfSymfony <https://friendsofsymfony.github.com/>
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 FOS\ElasticaBundle\DependencyInjection\Compiler;
13
14
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
15
use Symfony\Component\DependencyInjection\ContainerBuilder;
16
use Symfony\Component\DependencyInjection\Reference;
17
18
class IndexPass implements CompilerPassInterface
19
{
20
    /**
21
     * {@inheritdoc}
22
     */
23 10
    public function process(ContainerBuilder $container)
24
    {
25 10
        if (!$container->hasDefinition('fos_elastica.index_manager')) {
26
            return;
27
        }
28
29 10
        $indexes = [];
30 10
        foreach ($container->findTaggedServiceIds('fos_elastica.index') as $id => $tags) {
31 10
            foreach ($tags as $tag) {
32 10
                $indexes[$tag['name']] = new Reference($id);
33
            }
34
        }
35
36 10
        $container->getDefinition('fos_elastica.index_manager')->replaceArgument(0, $indexes);
37 10
    }
38
}
39