Passed
Pull Request — main (#22)
by Andrey
26:45 queued 11:50
created

File   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 29
rs 10
c 0
b 0
f 0
wmc 6

3 Methods

Rating   Name   Duplication   Size   Complexity  
A store() 0 5 1
A exists() 0 3 1
A all() 0 15 4
1
<?php
2
3
namespace Helldar\Support\Helpers\Filesystem;
4
5
use Helldar\Support\Exceptions\DirectoryNotFoundException;
6
7
class File
8
{
9
    public function all(string $path): array
10
    {
11
        if (Directory::doesntExist($path)) {
0 ignored issues
show
Bug Best Practice introduced by
The method Helldar\Support\Helpers\...irectory::doesntExist() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

11
        if (Directory::/** @scrutinizer ignore-call */ doesntExist($path)) {
Loading history...
12
            throw new DirectoryNotFoundException($path);
13
        }
14
15
        $files = [];
16
17
        foreach (Directory::all($path) as $iterator) {
0 ignored issues
show
Bug Best Practice introduced by
The method Helldar\Support\Helpers\...system\Directory::all() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

17
        foreach (Directory::/** @scrutinizer ignore-call */ all($path) as $iterator) {
Loading history...
18
            if ($iterator->isFile()) {
19
                $files[] = $files;
20
            }
21
        }
22
23
        return $files;
24
    }
25
26
    public function store(string $path, string $content)
27
    {
28
        Directory::make(pathinfo($path, PATHINFO_DIRNAME));
0 ignored issues
show
Bug Best Practice introduced by
The method Helldar\Support\Helpers\...ystem\Directory::make() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

28
        Directory::/** @scrutinizer ignore-call */ 
29
                   make(pathinfo($path, PATHINFO_DIRNAME));
Loading history...
29
30
        file_put_contents($path, $content);
31
    }
32
33
    public function exists(string $path): bool
34
    {
35
        return file_exists($path);
36
    }
37
}
38