Completed
Push — master ( 54c8d8...9da0fd )
by Tomáš
9s
created

ContainerFactory::create()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

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