Completed
Pull Request — master (#86)
by Alessandro
05:32
created

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