Completed
Branch master (6ff579)
by Tomasz
06:50 queued 03:50
created

Domain   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 1
A addModel() 0 8 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
12
class Domain extends AbstractAggregateRoot
13
{
14
    /** @var  Model[] */
15
    private $models;
16
17
    /**
18
     * Domain constructor.
19
     *
20
     * @param DomainId $id
21
     */
22
    public function __construct(DomainId $id)
23
    {
24
        parent::__construct($id);
25
        $this->models = [];
26
27
        $this->pushEvent(
28
            new DomainCreated(new \DateTime(), $this)
29
        );
30
    }
31
32
    public function addModel(Model $model)
33
    {
34
        $this->models[] = $model;
35
36
        $this->pushEvent(
37
            new ModelAdded(new \DateTime(), $model)
38
        );
39
    }
40
}
41