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

MoveFolderHandler::__invoke()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 6
nc 2
nop 1
dl 0
loc 10
ccs 6
cts 6
cp 1
crap 2
rs 9.4285
c 0
b 0
f 0
1
<?php
2
declare(strict_types = 1);
3
4
namespace PersonalGalaxy\Files\Handler;
5
6
use PersonalGalaxy\Files\{
7
    Command\MoveFolder,
8
    Repository\FolderRepository,
9
    Exception\FolderNotFound,
10
};
11
12
final class MoveFolderHandler
13
{
14
    private $repository;
15
16 2
    public function __construct(FolderRepository $repository)
17
    {
18 2
        $this->repository = $repository;
19 2
    }
20
21 2
    public function __invoke(MoveFolder $wished): void
22
    {
23 2
        if (!$this->repository->has($wished->parent())) {
24 1
            throw new FolderNotFound($wished->parent());
25
        }
26
27
        $this
28 1
            ->repository
29 1
            ->get($wished->identity())
30 1
            ->moveTo($wished->parent());
31 1
    }
32
}
33