Filesystem   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 0
cbo 1
dl 0
loc 37
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B rcopy() 0 33 4
1
<?php namespace Comodojo\Installer\Components;
2
3
use \RecursiveDirectoryIterator;
4
use \RecursiveIteratorIterator;
5
use \Composer\Util\Filesystem as ComposerFilesystem;
6
7
/**
8
 *
9
 *
10
 * @package     Comodojo Framework
11
 * @author      Marco Giovinazzi <[email protected]>
12
 * @author      Marco Castiello <[email protected]>
13
 * @license     GPL-3.0+
14
 *
15
 * LICENSE:
16
 *
17
 * This program is free software: you can redistribute it and/or modify
18
 * it under the terms of the GNU Affero General Public License as
19
 * published by the Free Software Foundation, either version 3 of the
20
 * License, or (at your option) any later version.
21
 *
22
 * This program is distributed in the hope that it will be useful,
23
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
25
 * GNU Affero General Public License for more details.
26
 *
27
 * You should have received a copy of the GNU Affero General Public License
28
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
29
 */
30
 
31
class Filesystem extends ComposerFilesystem {
32
    
33
    public function rcopy($source, $target) {
34
        
35
        if (!is_dir($source)) {
36
            
37
            copy($source, $target);
38
            
39
            return;
40
            
41
        }
42
        
43
        $it = new RecursiveDirectoryIterator($source, RecursiveDirectoryIterator::SKIP_DOTS);
44
        
45
        $ri = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::SELF_FIRST);
46
        
47
        $this->ensureDirectoryExists($target);
48
        
49
        foreach ($ri as $file) {
50
            
51
            $targetPath = $target . DIRECTORY_SEPARATOR . $ri->getSubPathName();
52
            
53
            if ($file->isDir()) {
54
                
55
                $this->ensureDirectoryExists($targetPath);
56
                
57
            } else {
58
                
59
                copy($file->getPathname(), $targetPath);
60
                
61
            }
62
            
63
        }
64
        
65
    }
66
    
67
}