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

EventHandler   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 20
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A fire() 0 4 1
A run() 0 4 2
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