SetonoDAOExtension::load()   A
last analyzed

Complexity

Conditions 4
Paths 8

Size

Total Lines 22
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 4
eloc 12
c 1
b 0
f 0
nc 8
nop 2
dl 0
loc 22
rs 9.8666
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Setono\DAOBundle\DependencyInjection;
6
7
use Symfony\Component\Config\FileLocator;
8
use Symfony\Component\DependencyInjection\ContainerBuilder;
9
use Symfony\Component\DependencyInjection\Extension\Extension;
10
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
11
12
final class SetonoDAOExtension extends Extension
13
{
14
    /**
15
     * {@inheritdoc}
16
     *
17
     * @throws \Exception
18
     */
19
    public function load(array $config, ContainerBuilder $container): void
20
    {
21
        $config = $this->processConfiguration($this->getConfiguration([], $container), $config);
0 ignored issues
show
Bug introduced by
It seems like $this->getConfiguration(array(), $container) 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

21
        $config = $this->processConfiguration(/** @scrutinizer ignore-type */ $this->getConfiguration([], $container), $config);
Loading history...
22
        $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
23
24
        $container->setParameter('setono_dao.customer_id', $config['customer_id']);
25
        $container->setParameter('setono_dao.password', $config['password']);
26
        $container->setParameter('setono_dao.base_url', $config['base_url']);
27
28
        if (isset($config['http_client'])) {
29
            $container->setParameter('setono_dao.http_client', $config['http_client']);
30
        }
31
32
        if (isset($config['request_factory'])) {
33
            $container->setParameter('setono_dao.request_factory', $config['request_factory']);
34
        }
35
36
        if (isset($config['stream_factory'])) {
37
            $container->setParameter('setono_dao.stream_factory', $config['stream_factory']);
38
        }
39
40
        $loader->load('services.xml');
41
    }
42
}
43