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

ContainerFactory   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 2
dl 0
loc 26
ccs 13
cts 13
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 4 1
A createWithConfig() 0 9 1
A createAndReturnTempDir() 0 8 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