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

UseCase::handle()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 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