Passed
Push — master ( 4489d6...729fd7 )
by 世昌
01:46
created

FileSystem::delete()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 6
nc 4
nop 1
dl 0
loc 12
rs 10
c 0
b 0
f 0
1
<?php
2
namespace nebula\application\filesystem;
3
4
use nebula\component\loader\Path;
5
use nebula\application\filesystem\FileHelper;
6
use nebula\application\filesystem\DirectoryHelper;
7
8
/**
9
 * 文件辅助函数
10
 */
11
class FileSystem implements FileSystemInterface
12
{
13
    use DirectoryHelper {
14
        make as protected;
15
        rm as protected;
16
        rmdirs as protected;
17
        move as moveDir;
18
        copy as copyDir;
19
    }
20
21
    use FileHelper  {
22
       delete as protected deleteFile;
23
       FileHelper::copy insteadof DirectoryHelper;
24
       FileHelper::move insteadof DirectoryHelper;
25
    }
26
27
28
29
    /**
30
     * 删除文件或者目录
31
     *
32
     * @param string $path
33
     * @return boolean
34
     */
35
    public static function delete(string $path):bool
36
    {
37
        if (($path=Path::format($path)) !== null) {
38
            if (is_file($path)) {
39
                return static::deleteFile($path);
40
            }
41
42
            if (is_dir($path)) {
43
                return static::rmDirs($path);
44
            }
45
        }
46
        return false;
47
    }
48
}
49