DomainEventRecording   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 21
rs 10
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A happened() 0 4 2
A eraseEvents() 0 3 1
A domainEvents() 0 3 1
1
<?php declare(strict_types=1);
2
3
namespace Stratadox\CardGame;
4
5
trait DomainEventRecording
6
{
7
    /** @var iterable|DomainEvent[] */
8
    protected $events = [];
9
10
    private function happened(DomainEvent ...$newEvents): void
11
    {
12
        foreach ($newEvents as $newEvent) {
13
            $this->events[] = $newEvent;
14
        }
15
    }
16
17
    /** @return DomainEvent[] */
18
    public function domainEvents(): iterable
19
    {
20
        return $this->events;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->events also could return the type iterable which is incompatible with the documented return type Stratadox\CardGame\DomainEvent[].
Loading history...
21
    }
22
23
    public function eraseEvents(): void
24
    {
25
        $this->events = [];
26
    }
27
}
28