RegisterClientsPass::process()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 2
Metric Value
dl 0
loc 12
ccs 8
cts 8
cp 1
rs 9.4285
cc 2
eloc 6
nc 2
nop 1
crap 2
1
<?php
2
3
/*
4
 * This file is part of the xAPI package.
5
 *
6
 * (c) Christian Flothmann <[email protected]>
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 Xabbuh\XApi\Bundle\ClientBundle\DependencyInjection\Compiler;
13
14
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
15
use Symfony\Component\DependencyInjection\ContainerBuilder;
16
use Symfony\Component\DependencyInjection\Reference;
17
18
/**
19
 * Compiler pass adding all configured xAPI clients to the xAPI client manager.
20
 *
21
 * @author Christian Flothmann <[email protected]>
22
 */
23
class RegisterClientsPass implements CompilerPassInterface
24
{
25
    /**
26
     * {@inheritDoc}
27
     */
28 3
    public function process(ContainerBuilder $container)
29
    {
30 3
        $definition = $container->getDefinition('xabbuh_xapi_client.client_manager');
31
32 3
        $clients = array();
33
34 3
        foreach ($container->getParameter('xabbuh_xapi_client.clients') as $name => $id) {
35 2
            $clients[$name] = new Reference($id);
36 3
        }
37
38 3
        $definition->setArguments(array($clients));
39 3
    }
40
}
41