Code Duplication    Length = 14-14 lines in 2 locations

src/Folder.php 2 locations

@@ 17-30 (lines=14) @@
14
     *
15
     * @throws \RuntimeException
16
     */
17
    public static function ensure($path, $mode = 0777)
18
    {
19
        if (is_dir($path)) {
20
            return;
21
        }
22
        if (@mkdir($path, $mode, true)) {
23
            return;
24
        }
25
        throw new \RuntimeException(sprintf(
26
            "Unable to create folder '%s': %s",
27
            $path,
28
            error_get_last()['message']
29
        ));
30
    }
31
32
    /**
33
     * Delete a directory and all of its contents recursively.
@@ 39-52 (lines=14) @@
36
     *
37
     * @throws \RuntimeException Thrown when something could not be deleted.
38
     */
39
    public static function delete($path)
40
    {
41
        if (!is_dir($path)) {
42
            return;
43
        }
44
        self::deleteContents($path);
45
        if (@rmdir($path) === false) {
46
            throw new \RuntimeException(sprintf(
47
                "Unable to delete folder '%s': %s",
48
                $path,
49
                error_get_last()['message']
50
            ));
51
        }
52
    }
53
54
    /**
55
     * deleteContents of a folder recursively, but not the folder itself.