Passed
Push — main ( 1d1c5b...83bc52 )
by Daniel
04:23
created

EventHandler   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
eloc 5
dl 0
loc 20
ccs 6
cts 6
cp 1
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 2
    public function __construct(
15
        private readonly ContainerInterface $dic
0 ignored issues
show
Bug introduced by
A parse error occurred: Syntax error, unexpected T_STRING, expecting T_VARIABLE on line 15 at column 25
Loading history...
16
    ) {
17
    }
18
19 1
    public function fire(
20
        callable $event
21
    ): void {
22 1
        $this->events[] = $event;
23
    }
24
25 2
    public function run(): void
26
    {
27 2
        foreach ($this->events as $event) {
28 1
            $event($this->dic);
29
        }
30
    }
31
}
32