Test Failed
Pull Request — master (#3)
by MediaCT
06:30
created

CopyFilesTrait   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 38
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A copyDirectory() 0 7 2
A copyFile() 0 8 1
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