Completed
Push — master ( 38f90d...223a4c )
by Peter
02:18
created

AggregateEventsTrait::pullEvents()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 7
c 0
b 0
f 0
ccs 0
cts 6
cp 0
rs 9.4285
cc 1
eloc 4
nc 1
nop 0
crap 2
1
<?php
2
/**
3
 * GpsLab component.
4
 *
5
 * @author    Peter Gribanov <[email protected]>
6
 * @copyright Copyright (c) 2016, Peter Gribanov
7
 * @license   http://opensource.org/licenses/MIT
8
 */
9
namespace GpsLab\Domain\Event\Aggregator;
10
11
use GpsLab\Domain\Event\EventInterface;
12
13
trait AggregateEventsTrait
14
{
15
    /**
16
     * @var EventInterface[]
17
     */
18
    private $events = [];
19
20
    /**
21
     * @return EventInterface[]
22
     */
23
    public function pullEvents()
24
    {
25
        $events = $this->events;
26
        $this->events = [];
27
28
        return $events;
29
    }
30
31
    /**
32
     * @param EventInterface $event
33
     */
34
    protected function raise(EventInterface $event)
35
    {
36
        $this->events[] = $event;
37
    }
38
}
39