RequestValidatorExtension   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 13
c 1
b 0
f 0
dl 0
loc 33
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A load() 0 17 2
A getAlias() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace MojtabaGheytasi\RequestValidatorBundle\DependencyInjection;
6
7
use Exception;
8
use Symfony\Component\Config\FileLocator;
9
use Symfony\Component\DependencyInjection\ContainerBuilder;
10
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
11
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
12
13
final class RequestValidatorExtension extends Extension
14
{
15
    /**
16
     * {@inheritDoc}
17
     *
18
     * @throws Exception
19
     */
20
    public function load(array $configs, ContainerBuilder $container)
21
    {
22
        $loader = new XmlFileLoader(
23
            $container,
24
            new FileLocator(__DIR__.'/../Resources/config')
25
        );
26
27
        $loader->load('services.xml');
28
29
        $configuration = $this->getConfiguration($configs, $container);
30
        $config = $this->processConfiguration($configuration, $configs);
0 ignored issues
show
Bug introduced by
It seems like $configuration can also be of type null; however, parameter $configuration of Symfony\Component\Depend...:processConfiguration() does only seem to accept Symfony\Component\Config...\ConfigurationInterface, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

30
        $config = $this->processConfiguration(/** @scrutinizer ignore-type */ $configuration, $configs);
Loading history...
31
32
        if (null !== $config['failed_validation']) {
33
            $container->setAlias(
34
                'request_validator.failed_validation',
35
                $config['failed_validation']
36
            )->setPublic(true);
37
        }
38
    }
39
40
    /**
41
     * {@inheritdoc}
42
     */
43
    public function getAlias(): string
44
    {
45
        return 'request_validator';
46
    }
47
}
48