Completed
Pull Request — master (#10)
by Tomáš
31:42
created

ContainerFactory::create()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 9
ccs 0
cts 8
cp 0
rs 9.6666
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 0
crap 2
1
<?php
2
3
/*
4
 * This file is part of Symplify
5
 * Copyright (c) 2016 Tomas Votruba (http://tomasvotruba.cz).
6
 */
7
8
namespace Symplify\MultiCodingStandard\DI;
9
10
use Nette\Configurator;
11
use Nette\DI\Container;
12
use Nette\Utils\FileSystem;
13
14
final class ContainerFactory
15
{
16
    public function create() : Container
17
    {
18
        $configurator = new Configurator();
19
        $configurator->setDebugMode(true);
20
        $configurator->setTempDirectory($this->createAndReturnTempDir());
21
        $configurator->addConfig(__DIR__ . '/../config/config.neon');
22
23
        return $configurator->createContainer();
24
    }
25
26
    private function createAndReturnTempDir() : string
27
    {
28
        $tempDir = sys_get_temp_dir() . '/_multi-cs';
29
        FileSystem::delete($tempDir);
30
        FileSystem::createDir($tempDir);
31
32
        return $tempDir;
33
    }
34
}
35