Passed
Push — main ( 199c59...bc8763 )
by Daniel
10:26
created

EventHandler::run()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 2
nc 2
nop 0
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Uxmp\Core\Component\Event;
6
7
use Psr\Container\ContainerInterface;
8
9
final class EventHandler implements EventHandlerInterface
10
{
11
    /** @var array<int, callable(ContainerInterface): void> */
12
    private array $events = [];
13
14 1
    public function __construct(
15
        private ContainerInterface $dic
16
    ) {
17 1
    }
18
19 1
    public function fire(
20
        callable $event
21
    ): void {
22 1
        $this->events[] = $event;
23 1
    }
24
25 1
    public function run(): void
26
    {
27 1
        foreach ($this->events as $event) {
28 1
            $event($this->dic);
29
        }
30 1
    }
31
}
32