ContainerFactory   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 3
lcom 0
cbo 2
dl 25
loc 25
rs 10
c 2
b 0
f 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 4 4 1
A createWithConfig() 8 8 1
A createAndReturnTempDir() 8 8 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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