UncommittedEvents::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
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