CopyDirectoryPlugin   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 20%

Importance

Changes 0
Metric Value
wmc 5
c 0
b 0
f 0
lcom 1
cbo 2
dl 0
loc 29
ccs 2
cts 10
cp 0.2
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getMethod() 0 4 1
A handle() 0 11 4
1
<?php
2
3
/*
4
 * This file is part of Rocketeer
5
 *
6
 * (c) Maxime Fabre <[email protected]>
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
13
namespace Rocketeer\Services\Filesystem\Plugins;
14
15
use League\Flysystem\Plugin\AbstractPlugin;
16
17
/**
18
 * Copy a directory somewhere.
19
 */
20
class CopyDirectoryPlugin extends AbstractPlugin
21
{
22
    /**
23
     * Get the method name.
24
     *
25
     * @return string
26
     */
27 442
    public function getMethod()
28
    {
29 442
        return 'copyDir';
30
    }
31
32
    /**
33
     * @param string $from
34
     * @param string $to
35
     * @param bool   $overwrite
36
     */
37
    public function handle($from, $to, $overwrite = false)
0 ignored issues
show
Comprehensibility introduced by Maxime Fabre
Avoid variables with short names like $to. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
38
    {
39
        foreach ($this->filesystem->listContents($from) as $file) {
40
            $newPath = $to.'/'.$file['basename'];
41
            if ($this->filesystem->has($newPath) && !$overwrite) {
42
                continue;
43
            }
44
45
            $this->filesystem->copy($file['path'], $newPath);
46
        }
47
    }
48
}
49