Test Failed
Pull Request — master (#3)
by MediaCT
03:44
created

CopyFilesTrait::copyDirectory()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 2
nc 2
nop 3
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
3
 * Copyright MediaCT. All rights reserved.
4
 * https://www.mediact.nl
5
 */
6
namespace Mediact\CodingStandard\PhpStorm\Patcher;
7
8
use Mediact\CodingStandard\PhpStorm\FilesystemInterface;
9
10
trait CopyFilesTrait
11
{
12
    /**
13
     * Copy a directory.
14
     *
15
     * @param FilesystemInterface $source
16
     * @param FilesystemInterface $destination
17
     * @param string              $path
18
     *
19
     * @return void
20
     */
21
    private function copyDirectory(
22
        FilesystemInterface $source,
23
        FilesystemInterface $destination,
24
        $path
25
    ) {
26
        foreach ($source->listFiles($path) as $filePath) {
27
            $this->copyFile($source, $destination, $filePath);
28
        }
29
    }
30
31
    /**
32
     * Copy a file.
33
     *
34
     * @param FilesystemInterface $source
35
     * @param FilesystemInterface $destination
36
     * @param string              $path
37
     *
38
     * @return void
39
     */
40
    private function copyFile(
41
        FilesystemInterface $source,
42
        FilesystemInterface $destination,
43
        $path
44
    ) {
45
        $destination->put(
46
            $path,
47
            $source->read($path)
48
        );
49
    }
50
}
51