OsHelper   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 4
eloc 8
c 1
b 0
f 1
dl 0
loc 24
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A tempDirectory() 0 3 1
A tempFile() 0 3 1
A makeTempDirectory() 0 6 1
A randomFileName() 0 4 1
1
<?php
2
3
namespace Gameap\Helpers;
4
5
class OsHelper
6
{
7
    public static function tempFile(): string
8
    {
9
        return tempnam(self::tempDirectory(), self::randomFileName());
10
    }
11
12
    public static function tempDirectory(): string
13
    {
14
        return sys_get_temp_dir();
15
    }
16
17
    public static function makeTempDirectory(): string
18
    {
19
        $directory = self::tempDirectory() . "/" . self::randomFileName();
20
        mkdir($directory);
21
22
        return $directory;
23
    }
24
25
    private static function randomFileName(): string
26
    {
27
        $bytes = random_bytes(6);
28
        return bin2hex($bytes);
29
    }
30
}
31