UseCase   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 8
c 1
b 0
f 0
dl 0
loc 27
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A handle() 0 5 1
A __construct() 0 4 1
1
<?php
2
/**
3
 *
4
 * This file is part of the Aggrego.
5
 * (c) Tomasz Kunicki <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 *
10
 */
11
12
declare(strict_types = 1);
13
14
namespace Aggrego\Domain\Api\Command\TransformBoard;
15
16
use Aggrego\Domain\Api\Command\TransformBoard\Exception\InvalidCommandDataException;
17
use Aggrego\Domain\Board\FromBoardFactory;
18
use Aggrego\Domain\Board\Repository;
19
20
class UseCase
21
{
22
    /**
23
     * @var Repository
24
     */
25
    private $repository;
26
27
    /**
28
     * @var FromBoardFactory
29
     */
30
    private $factory;
31
32
    public function __construct(Repository $repository, FromBoardFactory $factory)
33
    {
34
        $this->repository = $repository;
35
        $this->factory = $factory;
36
    }
37
38
    /**
39
     * @param  Command $command
40
     * @throws InvalidCommandDataException
41
     */
42
    public function handle(Command $command): void
43
    {
44
        $board = $this->repository->getBoardByUuid($command->getBoardUuid());
45
        $newBoard = $this->factory->fromBoard($command->getKey(), $board);
46
        $this->repository->addBoard($newBoard);
47
    }
48
}
49