Passed
Push — master ( 2ee0d1...1e8995 )
by Tomasz
03:21
created

UseCase::handle()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

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