HappyrSerializerExtension   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 6

Test Coverage

Coverage 58.81%

Importance

Changes 4
Bugs 0 Features 2
Metric Value
wmc 4
c 4
b 0
f 2
lcom 0
cbo 6
dl 0
loc 29
ccs 10
cts 17
cp 0.5881
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B load() 0 23 4
1
<?php
2
3
namespace Happyr\SerializerBundle\DependencyInjection;
4
5
use Symfony\Component\Config\FileLocator;
6
use Symfony\Component\DependencyInjection\ContainerBuilder;
7
use Symfony\Component\DependencyInjection\Loader;
8
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
9
10
/**
11
 * @author Tobias Nyholm <[email protected]>
12
 */
13
class HappyrSerializerExtension extends Extension
14
{
15
    /**
16
     * {@inheritdoc}
17
     */
18 23
    public function load(array $configs, ContainerBuilder $container)
19
    {
20 23
        $configuration = new Configuration();
21 23
        $config = $this->processConfiguration($configuration, $configs);
22
23 23
        $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
24 23
        $loader->load('services.yml');
25
26 23
        if ($config['twig_extension']) {
27
            $loader->load('twig.yml');
28
        }
29
30 23
        if (empty($config['source'])) {
31
            // Try to help
32
            $path = $container->getParameter('kernel.root_dir').'/../src';
33
            if (!is_dir($path)) {
34
                throw new \Exception('You must specify a path at happyr_serializer.source');
35
            }
36
            $config['source'] = [$path];
37
        }
38 23
        $container->getDefinition('happyr.serializer.metadata.annotation_reader')
39 23
            ->replaceArgument(0, $config['source']);
40 23
    }
41
}
42