LoadTrait::configure()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 25

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 25
rs 9.52
c 0
b 0
f 0
cc 2
nc 2
nop 0
1
<?php
2
3
namespace SfCod\SocketIoBundle\Tests\Data;
4
5
use Monolog\Logger;
6
use Psr\Log\LoggerInterface;
7
use SfCod\SocketIoBundle\DependencyInjection\SocketIoExtension;
8
use Symfony\Component\DependencyInjection\ContainerBuilder;
9
use Symfony\Component\Dotenv\Dotenv;
10
use Symfony\Component\Dotenv\Exception\PathException;
11
12
trait LoadTrait
13
{
14
    protected $container;
15
16
    protected function configure()
17
    {
18
        $dotenv = new Dotenv();
19
        try {
20
            $dotenv->load(__DIR__ . '/../../.env');
21
        } catch (PathException $e) {
22
            // Nothing
23
        }
24
25
        $extension = new SocketIoExtension();
26
        $container = new ContainerBuilder();
27
        $container->setParameter('kernel.project_dir', getenv('KERNEL_PROJECT_DIR'));
28
        $container->setParameter('kernel.root_dir', realpath(__DIR__ . '/../../../../SfCod/'));
29
        $container->set(LoggerInterface::class, new Logger('test'));
30
31
        $extension->load([
32
            0 => [
33
                'namespaces' => [
34
                    'SfCod\SocketIoBundle\Tests\Data',
35
                ],
36
            ],
37
        ], $container);
38
39
        $this->container = $container;
40
    }
41
}
42