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

EventHandler::fire()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 4
ccs 2
cts 2
cp 1
crap 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 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