Completed
Push — master ( 579f9d...c8145b )
by Alessandro
06:36
created

TempFilenameFactory::getTempFilename()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 9
ccs 6
cts 6
cp 1
rs 9.6666
cc 1
eloc 7
nc 1
nop 3
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 27
    public function __construct(TempDirectory $tempDirectory)
21
    {
22 27
        $this->tempDirectory = $tempDirectory;
23 27
    }
24
25
    /**
26
     * @param string $uniqueId
27
     * @return string
28
     */
29 25
    public function getFilenameForLog($uniqueId)
30
    {
31 25
        return $this->getTempFilename('logs', $uniqueId, '.json.log');
32
    }
33
34
    /**
35
     * @param string $uniqueId
36
     * @return string
37
     */
38 1
    public function getFilenameForCoverage($uniqueId)
39
    {
40 1
        return $this->getTempFilename('coverage', $uniqueId, '.php');
41
    }
42
43
    /**
44
     * @param string $filename
45
     * @param string $extension
46
     * @return string
47
     */
48 26
    private function getTempFilename($subdir, $filename, $extension)
49
    {
50 26
        return $this->tempDirectory->getTempDirForThisExecution()
51
            . DIRECTORY_SEPARATOR
52 26
            . $subdir
53 26
            . DIRECTORY_SEPARATOR
54 26
            . $filename
55 26
            . $extension;
56
    }
57
}
58