ContainerFactory   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 2
dl 0
loc 25
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 4 1
A createWithConfig() 0 8 1
A createAndReturnTempDirectory() 0 8 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Symplify\SymfonySecurity\Tests\Adapter\Nette;
6
7
use Nette\Configurator;
8
use Nette\DI\Container;
9
use Nette\Utils\FileSystem;
10
11
final class ContainerFactory
12
{
13
    public function create() : Container
14
    {
15
        return $this->createWithConfig(__DIR__ . '/config/default.neon');
16
    }
17
18
    public function createWithConfig(string $config) : Container
19
    {
20
        $configurator = new Configurator();
21
        $configurator->setTempDirectory($this->createAndReturnTempDirectory());
22
        $configurator->addConfig($config);
23
24
        return $configurator->createContainer();
25
    }
26
27
    private function createAndReturnTempDirectory() : string
28
    {
29
        $tempDir = sys_get_temp_dir() . '/symplify_symfony_security';
30
        FileSystem::delete($tempDir);
31
        FileSystem::createDir($tempDir);
32
33
        return $tempDir;
34
    }
35
}
36