EventGeneratorMethods   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 0
dl 0
loc 29
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A recordThat() 0 4 1
A releaseEvents() 0 6 1
1
<?php
2
3
/**
4
 * This file is part of slick/cqrs-tools
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
namespace Slick\CQRSTools\Event;
11
12
use Slick\CQRSTools\Event;
13
14
/**
15
 * Event Generator Methods
16
 *
17
 * @package Slick\CQRSTools\Event
18
 */
19
trait EventGeneratorMethods
20
{
21
    /**
22
     * @var array|Event[]
23
     */
24
    protected $events = [];
25
26
    /**
27
     * Records that a domain event has occurred
28
     *
29
     * @param Event $event
30
     */
31
    public function recordThat(Event $event): void
32
    {
33
        array_push($this->events, $event);
34
    }
35
36
    /**
37
     * Releases the previously recorded events
38
     *
39
     * @return Event[]|array
40
     */
41
    public function releaseEvents(): array
42
    {
43
        $events = $this->events;
44
        $this->events = [];
45
        return $events;
46
    }
47
}
48