Completed
Push — master ( 80ef2e...65d1c9 )
by
unknown
58:18 queued 18:37
created

LoadTrait   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 7

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 7
dl 0
loc 54
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B configure() 0 41 2
1
<?php
2
3
namespace SfCod\EmailEngineBundle\Tests\Data;
4
5
use Monolog\Logger;
6
use Psr\Container\ContainerInterface;
7
use Psr\Log\LoggerInterface;
8
use SfCod\EmailEngineBundle\DependencyInjection\EmailEngineExtension;
9
use Symfony\Component\DependencyInjection\ContainerBuilder;
10
use Symfony\Component\Dotenv\Dotenv;
11
use Symfony\Component\Dotenv\Exception\PathException;
12
13
/**
14
 * Trait LoadTrait
15
 *
16
 * @package SfCod\QueueBundle\Tests\Data
17
 */
18
trait LoadTrait
19
{
20
    /**
21
     * @var ContainerInterface
22
     */
23
    protected $container;
24
25
    /**
26
     * Configure container
27
     *
28
     * @throws \ReflectionException
29
     */
30
    protected function configure(string $sender, string $repository)
31
    {
32
        $dotenv = new Dotenv();
33
        try {
34
            $dotenv->load(__DIR__ . '/../../.env');
35
        } catch (PathException $e) {
36
            // Nothing
37
        }
38
39
        $extension = new EmailEngineExtension();
40
        $container = new ContainerBuilder();
41
        $container->setParameter('kernel.project_dir', getenv('KERNEL_PROJECT_DIR'));
42
        $container->setParameter('kernel.root_dir', realpath(__DIR__ . '/../../../../SfCod/'));
43
        $container->set(LoggerInterface::class, new Logger('test'));
44
        $container->set(\Swift_Mailer::class, new \Swift_Mailer(new \Swift_Transport_NullTransport(new \Swift_Events_SimpleEventDispatcher())));
45
46
        $extension->load([
47
            [
48
                'main_sender' => 'default',
49
            ],
50
            [
51
                'senders' => [
52
                    'default' => [
53
                        'sender' => [
54
                            'class' => $sender,
55
                        ],
56
                        'repository' => [
57
                            'class' => $repository,
58
                        ],
59
                    ],
60
                ],
61
            ],
62
            [
63
                'templates' => [
64
                    'SfCod\EmailEngineBundle\Example\TestEmailTemplate',
65
                ],
66
            ],
67
        ], $container);
68
69
        $this->container = $container;
70
    }
71
}
72