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

AggregateEventsTrait   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 0
dl 0
loc 26
c 0
b 0
f 0
ccs 0
cts 10
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A pullEvents() 0 7 1
A raise() 0 4 1
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