I18nRoutingExtension   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 6

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 6
dl 0
loc 32
ccs 15
cts 15
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getAlias() 0 4 1
A load() 0 12 1
A configureAnnotationLoader() 0 6 2
1
<?php
2
3
namespace FrankDeJonge\SymfonyI18nRouting\DependencyInjection;
4
5
use FrankDeJonge\SymfonyI18nRouting\DependencyInjection\CompilerPass\ReplaceRouterCompilerPass;
6
use Symfony\Component\Config\FileLocator;
7
use Symfony\Component\Config\Loader\LoaderInterface;
8
use Symfony\Component\DependencyInjection\ContainerBuilder;
9
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
10
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
11
12
class I18nRoutingExtension extends Extension
13
{
14 6
    public function getAlias()
15
    {
16 6
        return 'frankdejonge_i18n_routing';
17
    }
18
19
    /**
20
     * Loads a specific configuration.
21
     *
22
     * @throws \InvalidArgumentException When provided tag is not defined in this extension
23
     */
24 6
    public function load(array $configs, ContainerBuilder $container)
25
    {
26 6
        $loader = new PhpFileLoader(
27 6
            $container,
28 6
            new FileLocator(__DIR__ . '/../Resources/config/')
29
        );
30
31 6
        $loader->load('services.php');
32 6
        $config = $this->processConfiguration(new Configuration(), $configs);
33 6
        $container->setParameter('frankdejonge_i18n_routing.default_locale', $config['default_locale']);
34 6
        $this->configureAnnotationLoader($config, $loader);
35 6
    }
36
37 6
    private function configureAnnotationLoader(array $config, LoaderInterface $loader)
38
    {
39 6
        if ($config['use_annotations'] ?? false) {
40 2
            $loader->load('annotations.php');
41
        }
42
    }
43
}