TemporaryFile   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 34
ccs 9
cts 9
cp 1
rs 10
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A tempDir() 0 7 2
A create() 0 3 1
A setTempFolder() 0 3 1
1
<?php
2
3
/**
4
 * Copyright (c) Florian Krämer (https://florian-kraemer.net)
5
 * Licensed under The MIT License
6
 * For full copyright and license information, please see the LICENSE.txt
7
 * Redistributions of files must retain the above copyright notice.
8
 *
9
 * @copyright Copyright (c) Florian Krämer (https://florian-kraemer.net)
10
 * @author    Florian Krämer
11
 * @link      https://github.com/Phauthentic
12
 * @license   https://opensource.org/licenses/MIT MIT License
13
 */
14
15
declare(strict_types=1);
16
17
namespace Phauthentic\Infrastructure\Storage\Utility;
18
19
/**
20
 * Temporary File
21
 */
22
class TemporaryFile
23
{
24
    /**
25
     * @var string
26
     */
27
    protected static string $tempDir = '';
28
29
    /**
30
     * @param string $tempDir
31
     * @return void
32
     */
33 1
    public static function setTempFolder(string $tempDir): void
34
    {
35 1
        static::$tempDir = $tempDir;
36 1
    }
37
38
    /**
39
     * @return string
40
     */
41 1
    public static function tempDir(): string
42
    {
43 1
        if (static::$tempDir === '') {
44 1
            return sys_get_temp_dir();
45
        }
46
47 1
        return static::$tempDir;
48
    }
49
50
    /**
51
     * @return string
52
     */
53 1
    public static function create(): string
54
    {
55 1
        return tempnam(static::tempDir(), '');
56
    }
57
}
58