Completed
Push — master ( d37fab...069828 )
by Igor
02:14
created

Controller::removeFromDir()   B

Complexity

Conditions 8
Paths 13

Size

Total Lines 21
Code Lines 13

Duplication

Lines 21
Ratio 100 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 21
loc 21
rs 7.1428
cc 8
eloc 13
nc 13
nop 2
1
<?php
2
/**
3
 * @license MIT
4
 * @author Igor Sorokin <[email protected]>
5
 */
6
namespace Dspbee\Bundle\Console;
7
use Dspbee\Bundle\Common\TFileSystem;
8
9
/**
10
 * Console utility.
11
 *
12
 * Class Controller
13
 * @package Dspbee\Bundle\Console
14
 */
15
class Controller
16
{
17
    use TFileSystem;
18
19
    public static function process($root)
20
    {
21
        $server = filter_input_array(INPUT_SERVER);
22
        $argv = $server['argv'];
23
        array_shift($argv);
24
        switch ($argv[0]) {
25
            case 'cache:clear':
26
                if ($handle = opendir($root)) {
27
                    while (false !== ($entry = readdir($handle))) {
28
                        if ($entry != "." && $entry != "..") {
29
                            $path = $root . '/' . $entry . '/view/cache';
30
                            if (file_exists($path)) {
31
                                self::removeFromDir($path);
32
                            }
33
                        }
34
                    }
35
                    closedir($handle);
36
                }
37
                break;
38
            default:
39
                echo "\nAvailable commands:\n\n";
40
                echo "cache:clear\n";
41
        }
42
    }
43
}