AddFolderHandler::__invoke()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 7
nc 2
nop 1
dl 0
loc 11
ccs 8
cts 8
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\AddFolder,
8
    Repository\FolderRepository,
9
    Entity\Folder,
10
    Exception\FolderNotFound,
11
};
12
13
final class AddFolderHandler
14
{
15
    private $repository;
16
17 2
    public function __construct(FolderRepository $repository)
18
    {
19 2
        $this->repository = $repository;
20 2
    }
21
22 2
    public function __invoke(AddFolder $wished): void
23
    {
24 2
        if (!$this->repository->has($wished->parent())) {
25 1
            throw new FolderNotFound($wished->parent());
26
        }
27
28 1
        $this->repository->add(
29 1
            Folder::add(
30 1
                $wished->identity(),
31 1
                $wished->name(),
32 1
                $wished->parent()
33
            )
34
        );
35 1
    }
36
}
37