PgsHashIdExtension::load()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 18
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 10
c 1
b 0
f 0
nc 3
nop 2
dl 0
loc 18
ccs 11
cts 11
cp 1
crap 3
rs 9.9332
1
<?php
2
3
namespace Pgs\HashIdBundle\DependencyInjection;
4
5
use Doctrine\Common\Annotations\AnnotationRegistry;
6
use Pgs\HashIdBundle\Annotation\Hash;
7
use Symfony\Component\Config\FileLocator;
8
use Symfony\Component\DependencyInjection\ContainerBuilder;
9
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
10
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
11
12
class PgsHashIdExtension extends Extension
13
{
14 2
    public function load(array $configs, ContainerBuilder $container): void
15
    {
16 2
        $loaderXml = new XmlFileLoader(
17 2
            $container,
18 2
            new FileLocator(__DIR__.'/../Resources/config')
19
        );
20 2
        $loaderXml->load('services.xml');
21
22 2
        $configuration = new Configuration();
23 2
        $config = $this->processConfiguration($configuration, $configs);
24
25 2
        foreach ($config[Configuration::NODE_CONVERTER] as $converter => $parameters) {
26 2
            foreach ($parameters as $parameter => $value) {
27 2
                $container->setParameter(sprintf('pgs_hash_id.converter.%s.%s', $converter, $parameter), $value);
28
            }
29
        }
30
31 2
        $this->registerAnnotation();
32 2
    }
33
34 2
    private function registerAnnotation(): void
35
    {
36 2
        AnnotationRegistry::loadAnnotationClass(Hash::class);
37 2
    }
38
}
39