Passed
Push — master ( 5e83b7...81caf8 )
by Tomasz
02:02
created

UseCase::handle()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 5
c 0
b 0
f 0
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace Aggrego\Domain\Api\Command\TransformBoard;
6
7
use Aggrego\Domain\Api\Command\TransformBoard\Exception\InvalidCommandDataException;
8
use Aggrego\Domain\Board\Factory;
9
use Aggrego\Domain\Board\Repository;
10
11
class UseCase
12
{
13
    /** @var Repository */
14
    private $repository;
15
16
    /** @var Factory */
17
    private $factory;
18
19
    public function __construct(Repository $repository, Factory $factory)
20
    {
21
        $this->repository = $repository;
22
        $this->factory = $factory;
23
    }
24
25
    /**
26
     * @param Command $command
27
     * @throws InvalidCommandDataException
28
     */
29
    public function handle(Command $command): void
30
    {
31
        $board = $this->repository->getBoardByUuid($command->getBoardUuid());
32
        $newBoard = $this->factory->fromBoard($board);
33
        $this->repository->addBoard($newBoard);
34
    }
35
}
36