ContainerFactory::createContainer()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 6
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 9
ccs 4
cts 4
cp 1
crap 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * neuralyzer : Data Anonymization Library and CLI Tool
7
 *
8
 * PHP Version 7.2
9
 *
10
 * @author    Emmanuel Dyan
11
 *
12
 * @copyright 2020 Emmanuel Dyan
13
 *
14
 * @package edyan/neuralyzer
15
 *
16
 * @license GNU General Public License v2.0
17
 *
18
 * @link https://github.com/edyan/neuralyzer
19
 */
20
21
namespace Edyan\Neuralyzer;
22
23
use Symfony\Component\Config\FileLocator;
24
use Symfony\Component\Console\DependencyInjection\AddConsoleCommandPass;
25
use Symfony\Component\DependencyInjection\ContainerBuilder;
26
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
27
28
/**
29
 * Class ContainerFactory
30
 *
31
 * @package edyan/neuralyzer
32
 */
33
class ContainerFactory
34 71
{
35
    /**
36 71
     * @throws \Exception
37 71
     */
38 71
    public static function createContainer(): ContainerBuilder
39 71
    {
40 71
        $container = new ContainerBuilder();
41
        $loader = new YamlFileLoader($container, new FileLocator(__DIR__ . '/../config'));
42 71
        $loader->load('services.yml');
43
        $container->addCompilerPass(new AddConsoleCommandPass());
44
        $container->compile();
45
46
        return $container;
47
    }
48
}
49