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

TempFilenameFactory::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 2
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