EventProviderTrait   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A raise() 0 4 1
A popEvents() 0 7 1
1
<?php
2
3
namespace GBProd\DomainEvent;
4
5
/**
6
 * Trait for event providers
7
 * 
8
 * @author gbprod <[email protected]>
9
 */
10
trait EventProviderTrait
11
{
12
    /**
13
     * @var array<DomainEvent>
14
     */
15
    private $events = [];
16
    
17
    /**
18
     * {@inheritdoc}
19
     */
20 1
    public function raise(DomainEvent $event)
21
    {
22 1
        $this->events[] = $event;
23 1
    }
24
    
25
    /**
26
     * {@inheritdoc}
27
     */
28 2
    public function popEvents()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
29
    {
30 2
        $events = $this->events;
31 2
        $this->events = [];
32
        
33 2
        return $events;
34
    }
35
}