Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
8 / 8
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
LoggerServiceProvider
100.00% covered (success)
100.00%
8 / 8
100.00% covered (success)
100.00%
2 / 2
2
100.00% covered (success)
100.00%
1 / 1
 register
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
1
 boot
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5namespace Engelsystem\Logger;
6
7use Engelsystem\Container\ServiceProvider;
8use Engelsystem\Helpers\Authenticator;
9use Psr\Log\LoggerInterface;
10
11class LoggerServiceProvider extends ServiceProvider
12{
13    public function register(): void
14    {
15        $logger = $this->app->make(UserAwareLogger::class);
16        $this->app->instance('logger', $logger);
17
18        $this->app->bind(LoggerInterface::class, 'logger');
19        $this->app->bind(Logger::class, 'logger');
20        $this->app->bind(UserAwareLogger::class, 'logger');
21    }
22
23    public function boot(): void
24    {
25        /** @var UserAwareLogger $logger */
26        $logger = $this->app->get(UserAwareLogger::class);
27        /** @var Authenticator $auth */
28        $auth = $this->app->get(Authenticator::class);
29
30        $logger->setAuth($auth);
31    }
32}