Completed
Push — master ( 1fe5d2...6a0fd3 )
by Tomasz
02:28
created

UseCase   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 5
dl 0
loc 27
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A handle() 0 11 1
1
<?php
2
3
namespace Hexarchium\CoreDomain\UseCase\CreateUseCase;
4
5
use Hexarchium\CoreDomain\Model\Domain\Repository\DomainRepositoryInterface;
6
use Hexarchium\CoreDomain\Model\Domain\UseCase\Type;
7
8
class UseCase
9
{
10
    /** @var  DomainRepositoryInterface */
11
    private $domainRepository;
12
13
    /**
14
     * UseCase constructor.
15
     *
16
     * @param DomainRepositoryInterface $domainRepository
17
     */
18
    public function __construct(DomainRepositoryInterface $domainRepository)
19
    {
20
        $this->domainRepository = $domainRepository;
21
    }
22
23
    public function handle(Command $command)
24
    {
25
        $domain = $this->domainRepository->getById($command->getDomainId());
26
27
        $useCase = new \Hexarchium\CoreDomain\Model\Domain\Entity\UseCase(
28
            $command->getUseCaseId(),
29
            new Type($command->getUseCaseType())
30
        );
31
32
        $domain->addUseCase($useCase);
33
    }
34
}
35