Completed
Push — master ( e82c11...2c9024 )
by Tomáš
06:23
created

ContainerFactory   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

3 Methods

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