Completed
Pull Request — master (#94)
by Alessandro
04:33
created

TempFilenameFactory::getPathForLog()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 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 41
    public function __construct(TempDirectory $tempDirectory)
22
    {
23 41
        $this->tempDirectory = $tempDirectory;
24
    }
25
26 31
    public function getPathForLog(): string
27
    {
28 31
        return $this->getTempSubDir('logs');
29
    }
30
31
    /**
32
     * @param string $uniqueId
33
     * @return string
34
     */
35 30
    public function getFilenameForLog(string $uniqueId): string
36
    {
37 30
        return $this->getTempFilename('logs', $uniqueId, 'json.log');
38
    }
39
40 2
    public function getFilenameForCoverage(string $uniqueId): string
41
    {
42 2
        return $this->getTempFilename('coverage', $uniqueId, 'php');
43
    }
44
45 1
    public function getFilenameForConfiguration(): string
46
    {
47 1
        return $this->getTempFilename('config', 'phpunit', 'xml.dist');
48
    }
49
50 32
    private function getTempFilename(string $subDir, string $filename, string $extension): string
51
    {
52 32
        return $this->getTempSubDir($subDir)
53 32
            . $filename
54 32
            . '.'
55 32
            . $extension;
56
    }
57
58 33
    private function getTempSubDir(string $subDir): string
59
    {
60 33
        return $this->tempDirectory->getTempDirForThisExecution()
61 33
            . DIRECTORY_SEPARATOR
62 33
            . $subDir
63 33
            . DIRECTORY_SEPARATOR;
64
    }
65
}
66