Completed
Push — master ( 2a0b01...28b040 )
by Tomasz
02:38
created

Domain   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 4
dl 0
loc 40
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 1
A addModel() 0 8 1
A addUseCase() 0 7 1
1
<?php
2
/**
3
 * Copyright
4
 */
5
namespace Hexarchium\CoreDomain\Model\Domain\Entity;
6
7
use Hexarchium\CoreDomain\Aggregate\AbstractAggregateRoot;
8
use Hexarchium\CoreDomain\Model\Domain\DomainId;
9
use Hexarchium\CoreDomain\Model\Domain\Events\DomainCreated;
10
use Hexarchium\CoreDomain\Model\Domain\Events\ModelAdded;
11
use Hexarchium\CoreDomain\Model\Domain\Events\UseCaseAdded;
12
13
class Domain extends AbstractAggregateRoot
14
{
15
    /** @var  Model[] */
16
    private $models;
17
18
    /** @var  UseCase[] */
19
    private $useCases;
20
21
    /**
22
     * Domain constructor.
23
     *
24
     * @param DomainId $id
25
     */
26
    public function __construct(DomainId $id)
27
    {
28
        parent::__construct($id);
29
        $this->models = [];
30
31
        $this->pushEvent(
32
            new DomainCreated(new \DateTime(), $this)
33
        );
34
    }
35
36
    public function addModel(Model $model)
37
    {
38
        $this->models[] = $model;
39
40
        $this->pushEvent(
41
            new ModelAdded(new \DateTime(), $model)
42
        );
43
    }
44
45
    public function addUseCase(UseCase $useCase)
46
    {
47
        $this->useCases[] = $useCase;
48
        $this->pushEvent(
49
            new UseCaseAdded(new \DateTime(), $useCase)
50
        );
51
    }
52
}
53