LAShowroomTaxJarExtension::load()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 19
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 19
ccs 11
cts 11
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 11
nc 2
nop 2
crap 2
1
<?php
2
3
namespace LAShowroom\TaxJarBundle\DependencyInjection;
4
5
use Symfony\Component\DependencyInjection\ContainerBuilder;
6
use Symfony\Component\Config\FileLocator;
7
use Symfony\Component\DependencyInjection\Reference;
8
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
9
use Symfony\Component\DependencyInjection\Loader;
10
11
class LAShowroomTaxJarExtension extends Extension
12
{
13
    /**
14
     * {@inheritdoc}
15
     */
16 6
    public function load(array $configs, ContainerBuilder $container)
17
    {
18 6
        $configuration = new Configuration();
19 6
        $config = $this->processConfiguration($configuration, $configs);
20
21 4
        $loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
22 4
        $loader->load('services.xml');
23
24 4
        $container->setParameter('la_showroom_tax_jar.api_token', $config['api_token']);
25
26 4
        if (!empty($config['cache'])) {
27
            $container
28 2
                ->getDefinition('la_showroom_tax_jar.client')
29 2
                ->addMethodCall('setCacheItemPool', [
30 2
                    new Reference($config['cache'])
31
                ])
32
            ;
33
        }
34 4
    }
35
}
36