Passed
Push — develop ( eaa894...ad515c )
by Baptiste
01:56
created

RemoveFileHandler   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 20
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 7 1
A __construct() 0 6 1
1
<?php
2
declare(strict_types = 1);
3
4
namespace PersonalGalaxy\Files\Handler;
5
6
use PersonalGalaxy\Files\{
7
    Command\RemoveFile,
8
    Repository\FileRepository,
9
};
10
use Innmind\Filesystem\Adapter;
11
12
final class RemoveFileHandler
13
{
14
    private $repository;
15
    private $filesystem;
16
17 3
    public function __construct(
18
        FileRepository $repository,
19
        Adapter $filesystem
20
    ) {
21 3
        $this->repository = $repository;
22 3
        $this->filesystem = $filesystem;
23 3
    }
24
25 3
    public function __invoke(RemoveFile $wished): void
26
    {
27 3
        $file = $this->repository->get($wished->identity());
28 3
        $file->remove();
29
30 3
        $this->repository->remove($file->identity());
31 3
        $this->filesystem->remove((string) $file->name());
32 3
    }
33
}
34