TempFilenameFactory::getFilenameForConfiguration()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

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