TempFilenameFactory   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 1
dl 0
loc 50
ccs 20
cts 20
cp 1
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getPathForLog() 0 4 1
A getFilenameForLog() 0 4 1
A getFilenameForCoverage() 0 4 1
A getFilenameForConfiguration() 0 4 1
A getTempFilename() 0 7 1
A getTempSubDir() 0 7 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