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

UseCase   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 22
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

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