CopyFilesTrait::copyDirectory()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2

Importance

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