Passed
Push — master ( 35eebd...7b8a1a )
by Roman
16:45
created

AggregateRoot   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 23
ccs 0
cts 9
cp 0
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A clearEvents() 0 3 1
A popEvents() 0 6 1
A raise() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Game\Features\Player;
6
7
abstract class AggregateRoot implements RaiseEventsInterface
8
{
9
    /**
10
     * @var DomainEventInterface[]
11
     */
12
    protected array $events = [];
13
14
    public function popEvents(): array
15
    {
16
        $events = $this->events;
17
        $this->events = [];
18
19
        return $events;
20
    }
21
22
    public function clearEvents(): void
23
    {
24
        $this->events = [];
25
    }
26
27
    public function raise(DomainEventInterface $event): void
28
    {
29
        $this->events[] = $event;
30
    }
31
}
32