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
namespace Symnedi\Security\Tests;
4
5
use Nette\Configurator;
6
use Nette\DI\Container;
7
use Nette\Utils\FileSystem;
8
9
final class ContainerFactory
10
{
11
    public function create() : Container
12
    {
13
        return $this->createWithConfig(__DIR__ . '/config/default.neon');
14
    }
15
16
    public function createWithConfig(string $config) : Container
17
    {
18
        $configurator = new Configurator();
19
        $configurator->setTempDirectory($this->createAndReturnTempDirectory());
20
        $configurator->addConfig($config);
21
22
        return $configurator->createContainer();
23
    }
24
25
    private function createAndReturnTempDirectory() : string
26
    {
27
        $tempDir = sys_get_temp_dir() . '/symnedi_security';
28
        FileSystem::delete($tempDir);
29
        FileSystem::createDir($tempDir);
30
31
        return $tempDir;
32
    }
33
}
34