Code Duplication    Length = 22-22 lines in 2 locations

src/Gaufrette/Adapter/Local/tests/Gaufrette/Functional/Adapter/LocalTest.php 1 location

@@ 24-45 (lines=22) @@
21
        $this->filesystem = new Filesystem(new Local($this->directory));
22
    }
23
24
    public function tearDown()
25
    {
26
        $this->filesystem = null;
27
28
        if (file_exists($this->directory)) {
29
            $iterator = new \RecursiveIteratorIterator(
30
                new \RecursiveDirectoryIterator(
31
                    $this->directory,
32
                    \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::UNIX_PATHS
33
                ),
34
                \RecursiveIteratorIterator::CHILD_FIRST
35
            );
36
37
            foreach ($iterator as $item) {
38
                if ($item->isDir()) {
39
                    rmdir(strval($item));
40
                } else {
41
                    unlink(strval($item));
42
                }
43
            }
44
        }
45
    }
46
47
    /**
48
     * @test

src/Gaufrette/Adapter/Local/tests/Gaufrette/Functional/Adapter/SafeLocalTest.php 1 location

@@ 19-40 (lines=22) @@
16
        $this->filesystem = new Filesystem(new SafeLocal($this->getDirectory()));
17
    }
18
19
    public function tearDown()
20
    {
21
        $this->filesystem = null;
22
23
        if (file_exists($this->getDirectory())) {
24
            $iterator = new \RecursiveIteratorIterator(
25
                new \RecursiveDirectoryIterator(
26
                    $this->getDirectory(),
27
                    \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::UNIX_PATHS
28
                ),
29
                \RecursiveIteratorIterator::CHILD_FIRST
30
            );
31
32
            foreach ($iterator as $item) {
33
                if ($item->isDir()) {
34
                    rmdir(strval($item));
35
                } else {
36
                    unlink(strval($item));
37
                }
38
            }
39
        }
40
    }
41
42
    private function getDirectory()
43
    {