Completed
Push — master ( fc4ead...c5d222 )
by Andrii
05:51
created

EventAwareTrait::releaseEvents()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 6
ccs 0
cts 3
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
4
namespace hiqdev\php\billing\event;
5
6
use League\Event\EventInterface;
0 ignored issues
show
Bug introduced by
The type League\Event\EventInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
8
/**
9
 * Trait EventTrait
10
 *
11
 * @author Dmytro Naumenko <[email protected]>
12
 */
13
trait EventAwareTrait
14
{
15
    /**
16
     * @var EventInterface[]
17
     */
18
    private $events = [];
19
20
    /**
21
     * Registers that $event occurred
22
     * @param EventInterface $event
23
     */
24
    public function recordThat(EventInterface $event): void
25
    {
26
        $this->events[] = $event;
27
    }
28
29
    /**
30
     * @return EventInterface[] of occurred events
31
     */
32
    public function releaseEvents(): array
33
    {
34
        $events = $this->events;
35
        $this->events = [];
36
37
        return $events;
38
    }
39
}
40