ContainerFactory   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 21
loc 21
ccs 0
cts 15
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 9 9 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
/*
6
 * This file is part of Symplify
7
 * Copyright (c) 2016 Tomas Votruba (http://tomasvotruba.cz).
8
 */
9
10
namespace Symplify\MultiCodingStandard\DI;
11
12
use Nette\Configurator;
13
use Nette\DI\Container;
14
use Nette\Utils\FileSystem;
15
16 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...
17
{
18
    public function create() : Container
19
    {
20
        $configurator = new Configurator();
21
        $configurator->setDebugMode(true);
22
        $configurator->setTempDirectory($this->createAndReturnTempDir());
23
        $configurator->addConfig(__DIR__.'/../config/config.neon');
24
25
        return $configurator->createContainer();
26
    }
27
28
    private function createAndReturnTempDir() : string
29
    {
30
        $tempDir = sys_get_temp_dir().'/symplify_multi_cs';
31
        FileSystem::delete($tempDir);
32
        FileSystem::createDir($tempDir);
33
34
        return $tempDir;
35
    }
36
}
37