PgsHashIdExtension::registerAnnotation()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
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