CopyFiles::handle()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 10
rs 10
c 0
b 0
f 0
cc 3
nc 3
nop 2
1
<?php
2
3
namespace HotRodCli\Jobs\Filesystem;
4
5
use Symfony\Component\Finder\Finder;
6
use Symfony\Component\Filesystem\Filesystem;
7
use Symfony\Component\Filesystem\Exception\IOExceptionInterface;
8
9
class CopyFiles
10
{
11
    protected $finder;
12
13
    protected $filesystem;
14
15
    public function __construct(Finder $finder, Filesystem $filesystem)
16
    {
17
        $this->finder = $finder;
18
        $this->filesystem = $filesystem;
19
    }
20
21
    public function handle(string $src, string $dist)
22
    {
23
        if ($this->filesystem->exists($dist)) {
24
            throw new \Exception('Such module already exists');
25
        }
26
27
        try {
28
            $this->filesystem->mirror($src, $dist);
29
        } catch (IOExceptionInterface $exception) {
30
            throw new \Exception($exception->getMessage());
31
        }
32
    }
33
}
34