Completed
Pull Request — master (#59)
by Alessandro
05:25
created

ParallelConfiguration::buildContainer()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 11
ccs 7
cts 7
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 7
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Paraunit\Configuration;
4
5
use Paraunit\Parser\ParserCompilerPass;
6
use Symfony\Component\Config\FileLocator;
7
use Symfony\Component\Console\Input\InputInterface;
8
use Symfony\Component\DependencyInjection\ContainerBuilder;
9
use Symfony\Component\DependencyInjection\Definition;
10
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
11
use Symfony\Component\DependencyInjection\Reference;
12
use Symfony\Component\EventDispatcher\DependencyInjection\RegisterListenersPass;
13
14
/**
15
 * Class Paraunit
16
 * @package Paraunit\Configuration
17
 */
18
class ParallelConfiguration
19
{
20
    /**
21
     * @param InputInterface $input
22
     * @return ContainerBuilder
23
     */
24 41
    public function buildContainer(InputInterface $input)
25
    {
26 41
        $containerBuilder = new ContainerBuilder();
27
28 41
        $this->loadYamlConfiguration($containerBuilder);
29 41
        $this->registerEventDispatcher($containerBuilder);
30 41
        $this->loadCommandLineOptions($containerBuilder, $input);
31 41
        $containerBuilder->compile();
32
33 41
        return $containerBuilder;
34
    }
35
36
    /**
37
     * @param ContainerBuilder $containerBuilder
38
     * @return YamlFileLoader
39
     */
40 41
    protected function loadYamlConfiguration(ContainerBuilder $containerBuilder)
41
    {
42 41
        $loader = new YamlFileLoader($containerBuilder, new FileLocator(__DIR__ . '/../Resources/config/'));
43 41
        $loader->load('configuration.yml');
44 41
        $loader->load('file.yml');
45 41
        $loader->load('parser.yml');
46 41
        $loader->load('printer.yml');
47 41
        $loader->load('process.yml');
48 41
        $loader->load('services.yml');
49 41
        $loader->load('test_result.yml');
50 41
        $loader->load('test_result_container.yml');
51 41
        $loader->load('test_result_format.yml');
52
53 41
        return $loader;
54
    }
55
56
    /**
57
     * @param ContainerBuilder $containerBuilder
58
     */
59 41
    private function registerEventDispatcher(ContainerBuilder $containerBuilder)
60
    {
61 41
        $containerBuilder->addCompilerPass(new RegisterListenersPass());
62 41
        $containerBuilder->addCompilerPass(new ParserCompilerPass());
63
64 41
        $containerBuilder->setDefinition(
65 41
            'event_dispatcher',
66 41
            new Definition(
67 41
                'Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher',
68 41
                array(new Reference('service_container'))
69 41
            )
70 41
        );
71 41
    }
72
73 41
    protected function loadCommandLineOptions(ContainerBuilder $containerBuilder, InputInterface $input)
74
    {
75 41
    }
76
}
77