AddFolderHandler::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
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