AddFolderHandler   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 11 2
A __construct() 0 3 1
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