Completed
Push — master ( cfda60...9a8bcf )
by Olivier
05:15
created

DBALTablePass::process()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 6.7441

Importance

Changes 0
Metric Value
dl 0
loc 14
ccs 4
cts 9
cp 0.4444
rs 9.7998
c 0
b 0
f 0
cc 4
nc 4
nop 1
crap 6.7441
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Shapin\Datagen\Bridge\Symfony\Bundle\DependencyInjection\Compiler;
6
7
use Shapin\Datagen\DBAL\Loader;
8
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
9
use Symfony\Component\DependencyInjection\ContainerBuilder;
10
use Symfony\Component\DependencyInjection\Reference;
11
12
class DBALTablePass 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.dbal_table') as $id => $tags) {
19
            $groups = [];
20
            foreach ($tags as $attributes) {
21
                if (isset($attributes['group'])) {
22
                    $groups[] = $attributes['group'];
23
                }
24
            }
25
            $loader->addMethodCall('addTable', [new Reference($id), $groups]);
26
        }
27 1
    }
28
}
29