EventStorage::release()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
c 0
b 0
f 0
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
namespace hiapi\event;
4
5
use hiapi\event\EventStorageInterface;
6
7
/**
8
 * Class EventStorage
9
 *
10
 * @author Dmytro Naumenko <[email protected]>
11
 */
12
class EventStorage implements EventStorageInterface
13
{
14
    /**
15
     * @var array
16
     */
17
    protected $events = [];
18
19
    /**
20
     * @param object ...$events
21
     */
22
    public function store(...$events): void
23
    {
24
        $this->events = array_merge($this->events, $events);
25
    }
26
27
    public function release(): array
28
    {
29
        $events = $this->events;
30
        $this->events = [];
31
32
        return $events;
33
    }
34
}
35