Passed
Pull Request — master (#265)
by Pascal
02:35
created

TemporaryDirectories::manager()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 3
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 7
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A TemporaryDirectories::create() 0 5 1
1
<?php
2
3
namespace ProtoneMedia\LaravelFFMpeg\Filesystem;
4
5
use Illuminate\Filesystem\Filesystem;
6
use Illuminate\Support\Str;
7
8
class TemporaryDirectories
9
{
10
    private static $directories = [];
11
12
    public static function create(): string
13
    {
14
        $directory = static::$directories[] = Str::random();
0 ignored issues
show
Bug introduced by
Since $directories is declared private, accessing it with static will lead to errors in possible sub-classes; you can either use self, or increase the visibility of $directories to at least protected.
Loading history...
15
16
        return storage_path("ffmpeg_temp/{$directory}");
17
    }
18
19
    /**
20
     * Loop through all directories and delete them.
21
     */
22
    public static function deleteAll(): void
23
    {
24
        foreach (static::$directories as $directory) {
0 ignored issues
show
Bug introduced by
Since $directories is declared private, accessing it with static will lead to errors in possible sub-classes; you can either use self, or increase the visibility of $directories to at least protected.
Loading history...
25
            (new Filesystem)->deleteDirectory(
26
                storage_path("ffmpeg_temp/{$directory}")
27
            );
28
        }
29
30
        static::$directories = [];
31
    }
32
}
33