Completed
Push — master ( 9a7b87...ad20a3 )
by Alessandro
03:07
created

TempFilenameFactory   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 1
dl 0
loc 50
ccs 0
cts 34
cp 0
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getPathForLog() 0 4 1
A getFilenameForLog() 0 4 1
A getFilenameForCoverage() 0 4 1
A getFilenameForConfiguration() 0 4 1
A getTempFilename() 0 7 1
A getTempSubDir() 0 7 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Paraunit\Configuration;
5
6
use Paraunit\File\TempDirectory;
7
8
/**
9
 * Class TempFilenameFactory
10
 * @package Tests\Unit\Parser
11
 */
12
class TempFilenameFactory
13
{
14
    /** @var TempDirectory */
15
    private $tempDirectory;
16
17
    /**
18
     * TempFilenameFactory constructor.
19
     * @param TempDirectory $tempDirectory
20
     */
21
    public function __construct(TempDirectory $tempDirectory)
22
    {
23
        $this->tempDirectory = $tempDirectory;
24
    }
25
26
    public function getPathForLog(): string
27
    {
28
        return $this->getTempSubDir('logs');
29
    }
30
31
    public function getFilenameForLog(string $uniqueId): string
32
    {
33
        return $this->getTempFilename('logs', $uniqueId, 'json.log');
34
    }
35
36
    public function getFilenameForCoverage(string $uniqueId): string
37
    {
38
        return $this->getTempFilename('coverage', $uniqueId, 'php');
39
    }
40
41
    public function getFilenameForConfiguration(): string
42
    {
43
        return $this->getTempFilename('config', 'phpunit', 'xml.dist');
44
    }
45
46
    private function getTempFilename(string $subDir, string $filename, string $extension): string
47
    {
48
        return $this->getTempSubDir($subDir)
49
            . $filename
50
            . '.'
51
            . $extension;
52
    }
53
54
    private function getTempSubDir(string $subDir): string
55
    {
56
        return $this->tempDirectory->getTempDirForThisExecution()
57
            . DIRECTORY_SEPARATOR
58
            . $subDir
59
            . DIRECTORY_SEPARATOR;
60
    }
61
}
62