Completed
Push — master ( 785877...e6b000 )
by Tobias
17:05
created

LoaderOrReaderPass::process()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 14
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 3

Importance

Changes 0
Metric Value
dl 0
loc 14
ccs 8
cts 8
cp 1
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 7
nc 3
nop 1
crap 3
1
<?php
2
3
/*
4
 * This file is part of the PHP Translation package.
5
 *
6
 * (c) PHP Translation team <[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 Translation\Bundle\DependencyInjection\CompilerPass;
13
14
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
15
use Symfony\Component\DependencyInjection\ContainerBuilder;
16
17
/**
18
 * To provide a BC layer for Symfony 2.7 to 3.3 this compiler pass
19
 * registers an alias of whether TranslationReader or TranslationLoader
20
 * to be able to inject it in other services.
21
 */
22
class LoaderOrReaderPass implements CompilerPassInterface
23
{
24 16
    public function process(ContainerBuilder $container)
25
    {
26 16
        if ($container->has('translation.reader')) {
27 1
            $container->setAlias('translation.loader_or_reader', 'translation.reader');
28
29 1
            return;
30
        }
31
32 15
        if ($container->has('translation.loader')) {
33 14
            $container->setAlias('translation.loader_or_reader', 'translation.loader');
34
35 14
            return;
36
        }
37 1
    }
38
}
39