EmptyDir::handle()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 3

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 12
ccs 9
cts 9
cp 1
rs 9.4285
cc 3
eloc 7
nc 3
nop 1
crap 3
1
<?php
2
3
namespace League\Flysystem\Plugin;
4
5
class EmptyDir extends AbstractPlugin
6
{
7
    /**
8
     * Get the method name.
9
     *
10
     * @return string
11
     */
12 3
    public function getMethod()
13
    {
14 3
        return 'emptyDir';
15
    }
16
17
    /**
18
     * Empty a directory's contents.
19
     *
20
     * @param $dirname
21
     */
22 3
    public function handle($dirname)
23
    {
24 3
        $listing = $this->filesystem->listContents($dirname, false);
25
26 3
        foreach ($listing as $item) {
27 3
            if ($item['type'] === 'dir') {
28 3
                $this->filesystem->deleteDir($item['path']);
29 3
            } else {
30 3
                $this->filesystem->delete($item['path']);
31
            }
32 3
        }
33 3
    }
34
}
35