JsonApiErrorResponseExtension   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 7

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 7
dl 0
loc 26
ccs 17
cts 17
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A load() 0 23 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Faecie\Bundle\JsonApiErrorResponseBundle\DependencyInjection;
6
7
use Faecie\Bundle\JsonApiErrorResponseBundle\ExceptionDescriber\PreconfiguredExceptionsDescriber;
8
use Faecie\Bundle\JsonApiErrorResponseBundle\JsonApi\Error;
9
use Symfony\Component\Config\FileLocator;
10
use Symfony\Component\DependencyInjection\ContainerBuilder;
11
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
12
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
13
14
class JsonApiErrorResponseExtension extends Extension
15
{
16 3
    public function load(array $configs, ContainerBuilder $container)
17
    {
18 3
        $config = $this->processConfiguration(new Configuration(), $configs);
19 3
        $loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config/'));
20 3
        $loader->load('config.xml');
21
22 3
        $errorObjects = [];
23 3
        $exceptionsConfiguration = $config['exceptions']['response'];
24
25 3
        foreach ($exceptionsConfiguration as $exception => $config) {
26 1
            $errorObjects[$exception] = new Error(
27 1
                $config[Configuration::EXCEPTION_ATTRIBUTE_CODE],
28 1
                $config[Configuration::EXCEPTION_ATTRIBUTE_ID],
29 1
                $config[Configuration::EXCEPTION_ATTRIBUTE_ABOUT],
30 1
                $config[Configuration::EXCEPTION_ATTRIBUTE_STATUS],
31 1
                $config[Configuration::EXCEPTION_ATTRIBUTE_TITLE],
32 1
                $config[Configuration::EXCEPTION_ATTRIBUTE_DETAIL]
33
            );
34
        }
35
36 3
        $container->getDefinition(PreconfiguredExceptionsDescriber::class)
37 3
            ->replaceArgument(0, $exceptionsConfiguration);
38 3
    }
39
}
40