TestCase::rmdir()   B
last analyzed

Complexity

Conditions 6
Paths 5

Size

Total Lines 18
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 18
c 0
b 0
f 0
rs 8.8571
cc 6
eloc 11
nc 5
nop 1
1
<?php
2
3
/**
4
 * This file is part of the Cubiche/Metadata component.
5
 *
6
 * Copyright (c) Cubiche
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Cubiche\Core\Metadata\Tests\Units;
13
14
use Cubiche\Tests\TestCase as BaseTestCase;
15
16
/**
17
 * TestCase class.
18
 *
19
 * Generated by TestGenerator on 2017-05-16 at 13:17:21.
20
 */
21
abstract class TestCase extends BaseTestCase
22
{
23
    /**
24
     * Remove directory when the directory is not empty.
25
     *
26
     * @param string $dir
27
     */
28
    protected function rmdir($dir)
29
    {
30
        if (is_dir($dir)) {
31
            $objects = scandir($dir);
32
            foreach ($objects as $object) {
33
                if ($object != '.' && $object != '..') {
34
                    if (filetype($dir.'/'.$object) == 'dir') {
35
                        $this->rmdir($dir.'/'.$object);
36
                    } else {
37
                        unlink($dir.'/'.$object);
38
                    }
39
                }
40
            }
41
42
            reset($objects);
43
            rmdir($dir);
44
        }
45
    }
46
}
47