Passed
Pull Request — master (#43)
by Sergei
11:45
created

DeferredEventsTrait   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 6
c 1
b 0
f 0
dl 0
loc 17
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A releaseEvents() 0 5 1
A recordEvent() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\EventDispatcher;
6
7
trait DeferredEventsTrait
8
{
9
    private array $recordedEvents = [];
10
11
    public function recordEvent(object $event): void
12
    {
13
        $this->recordedEvents[] = $event;
14
    }
15
16
    /**
17
     * @return object[]
18
     */
19
    public function releaseEvents(): array
20
    {
21
        $events = $this->recordedEvents;
22
        $this->recordedEvents = [];
23
        return $events;
24
    }
25
}
26