Completed
Push — master ( b28f87...a255d6 )
by Olivier
03:32
created

DBALFixturePass::process()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 4.0218

Importance

Changes 0
Metric Value
dl 0
loc 14
ccs 8
cts 9
cp 0.8889
rs 9.7998
c 0
b 0
f 0
cc 4
nc 4
nop 1
crap 4.0218
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Shapin\Datagen\Bridge\Symfony\Bundle\DependencyInjection\Compiler;
6
7
use Shapin\Datagen\Loader;
8
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
9
use Symfony\Component\DependencyInjection\ContainerBuilder;
10
use Symfony\Component\DependencyInjection\Reference;
11
12
class DBALFixturePass implements CompilerPassInterface
13
{
14 1
    public function process(ContainerBuilder $container)
15
    {
16 1
        $loader = $container->getDefinition(Loader::class);
17
18 1
        foreach ($container->findTaggedServiceIds('shapin_datagen.fixture') as $id => $tags) {
19 1
            $groups = [];
20 1
            foreach ($tags as $attributes) {
21 1
                if (isset($attributes['group'])) {
22
                    $groups[] = $attributes['group'];
23
                }
24
            }
25 1
            $loader->addMethodCall('addFixture', [new Reference($id), $groups]);
26
        }
27 1
    }
28
}
29