EventGeneratorBehavior   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A recordEvent() 0 6 1
A releaseEvents() 0 7 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace League\Event;
6
7
trait EventGeneratorBehavior
8
{
9
    /**
10
     * @var object[]
11
     */
12
    protected $events = [];
13
14
    /**
15
     * @return $this
16
     */
17
    protected function recordEvent(object $event): self
18
    {
19
        $this->events[] = $event;
20
21
        return $this;
22
    }
23
24
    /**
25
     * @return object[]
26
     */
27
    public function releaseEvents(): array
28
    {
29
        $events = $this->events;
30
        $this->events = [];
31
32
        return $events;
33
    }
34
}
35