UncommittedEvents::append()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
rs 9.4286
cc 2
eloc 4
nc 2
nop 1
1
<?php
2
3
namespace Domain\Eventing;
4
5
use Domain\Identity\Identity;
6
use Domain\Eventing\Exception\CorruptAggregateHistory;
7
8
/**
9
 * @author Sebastiaan Hilbers <[email protected]>
10
 */
11
class UncommittedEvents extends AbstractEventStream
12
{
13
    public function __construct(Identity $identity)
14
    {
15
        $this->identity = $identity;
16
    }
17
18
    public function append(DomainEvent $event)
19
    {
20
        if ($event->getAggregateIdentity() !== $this->identity) {
21
            throw new CorruptAggregateHistory('Event Identity is not matching the eventstreams\'s identity');
22
        }
23
24
        $this->events[] = $event;
25
    }
26
}
27