ContainerFactory::createAndReturnTempDir()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 8
Ratio 100 %

Importance

Changes 0
Metric Value
dl 8
loc 8
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Symplify\MultiCodingStandard\Tests;
6
7
use Nette\Configurator;
8
use Nette\DI\Container;
9
use Nette\Utils\FileSystem;
10
11 View Code Duplication
final class ContainerFactory
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
12
{
13
    public function create() : Container
14
    {
15
        return $this->createWithConfig(__DIR__.'/../src/config/config.neon');
16
    }
17
18
    public function createWithConfig($config) : Container
19
    {
20
        $configurator = new Configurator();
21
        $configurator->setTempDirectory($this->createAndReturnTempDir());
22
        $configurator->addConfig($config);
23
24
        return $configurator->createContainer();
25
    }
26
27
    private function createAndReturnTempDir() : string
28
    {
29
        $tempDir = sys_get_temp_dir().'/multi_cs';
30
        FileSystem::delete($tempDir);
31
        FileSystem::createDir($tempDir);
32
33
        return $tempDir;
34
    }
35
}
36