EventServiceProvider   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 3
dl 0
loc 16
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A register() 0 13 1
1
<?php
2
declare(strict_types=1);
3
4
namespace App\Providers;
5
6
use Illuminate\Container\Container;
7
use N1215\Tsukuyomi\Event\AppTerminating;
8
use N1215\Tsukuyomi\Event\EventManager;
9
use N1215\Tsukuyomi\Event\EventManagerInterface;
10
use Psr\Log\LoggerInterface;
11
12
class EventServiceProvider implements ServiceProviderInterface
13
{
14 1
    public function register(Container $container)
15
    {
16
        $container->singleton(EventManagerInterface::class, function (Container $container) {
17 1
            $eventManager = new EventManager();
18
19
            $eventManager->attach(AppTerminating::NAME, function (AppTerminating $event) use ($container) {
20 1
                $logger = $container->get(LoggerInterface::class);
21 1
                $logger->info('Event: ' . $event->getName());
22 1
            });
23
24 1
            return $eventManager;
25 1
        });
26 1
    }
27
}
28