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

TraitAggregate::initEvents()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 2
nc 2
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace Aggrego\Domain\Shared\Event\Model;
6
7
use Aggrego\Domain\Api\Application\Event\Event;
8
use Aggrego\Domain\Api\Application\Event\Events;
9
10
trait TraitAggregate
11
{
12
    /** @var Events */
13
    protected $events;
14
15
    private function initEvents(): void
16
    {
17
        if (is_null($this->events)) {
18
            $this->events = new Events();
19
        }
20
    }
21
22
    public function pullEvents(): Events
23
    {
24
        $this->initEvents();
25
        return $this->events;
26
    }
27
28
    protected function pushEvent(Event $event): void
29
    {
30
        $this->initEvents();
31
        $this->events->add($event);
32
    }
33
}
34