ProjetNormandieArticleExtension   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 20
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A load() 0 13 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace ProjetNormandie\ArticleBundle\DependencyInjection;
6
7
use ProjetNormandie\ArticleBundle\DependencyInjection\Configuration;
8
use Symfony\Component\DependencyInjection\ContainerBuilder;
9
use Symfony\Component\Config\FileLocator;
10
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
11
use Symfony\Component\DependencyInjection\Loader;
12
use Exception;
13
14
class ProjetNormandieArticleExtension extends Extension
15
{
16
    /**
17
     * @param array<mixed> $configs
18
     * @param ContainerBuilder $container
19
     * @throws Exception
20
     */
21
    public function load(array $configs, ContainerBuilder $container): void
22
    {
23
        $configuration = new Configuration();
24
        $config = $this->processConfiguration($configuration, $configs);
25
26
        $container->setParameter('projet_normandie_article.default_locale', $config['default_locale']);
27
        $container->setParameter('projet_normandie_article.supported_locales', $config['supported_locales']);
28
29
        $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../../config'));
30
        $loader->load('services.yml');
31
        $bundles = $container->getParameter('kernel.bundles');
32
        if (array_key_exists('SonataAdminBundle', $bundles)) {
0 ignored issues
show
Bug introduced by
It seems like $bundles can also be of type boolean and double and integer and string; however, parameter $array of array_key_exists() does only seem to accept ArrayObject|array, 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

32
        if (array_key_exists('SonataAdminBundle', /** @scrutinizer ignore-type */ $bundles)) {
Loading history...
33
            $loader->load('sonata_admin.yml');
34
        }
35
    }
36
}
37