Completed
Push — master ( 42f99d...2335a8 )
by Nikola
18:20 queued 03:48
created

getKnownRepositoryAliases()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
namespace RunOpenCode\Bundle\ExchangeRate\DependencyInjection\CompilerPass;
4
5
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
6
use Symfony\Component\DependencyInjection\ContainerBuilder;
7
8
class RepositoryCompilerPass implements CompilerPassInterface
9
{
10
    /**
11
     * {@inheritdoc}
12
     */
13
    public function process(ContainerBuilder $container)
14
    {
15
        $knownRepositories = $this->getKnownRepositoryAliases();
16
        $repositoryServiceId = $container->getParameter('run_open_code.exchange_rate.repository');
17
18
        $repositoryServiceId = isset($knownRepositories[$repositoryServiceId]) ? $knownRepositories[$repositoryServiceId] : $repositoryServiceId;
19
20
        if (!$container->hasDefinition($repositoryServiceId)) {
21
            throw new \RuntimeException(sprintf('Unknown repository service "%s" referenced in configuration.', $repositoryServiceId));
22
        }
23
24
        $container->setDefinition('run_open_code.exchange_rate.repository', $container->getDefinition($repositoryServiceId));
25
    }
26
27
    protected function getKnownRepositoryAliases()
28
    {
29
        return array(
30
            'file' => 'run_open_code.exchange_rate.repository.file_repository'
31
        );
32
    }
33
}
34