DomainEventRecording::domainEvents()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
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