Completed
Push — master ( e15c58...b150a8 )
by Changwan
07:08
created

MonologServiceProvider::boot()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 0
cts 3
cp 0
crap 2
rs 10
c 1
b 0
f 0
1
<?php
2
namespace Wandu\Bridges\Monolog;
3
4
use Monolog\Handler\StreamHandler;
5
use Monolog\Logger;
6
use Psr\Log\LoggerInterface;
7
use Wandu\DI\ContainerInterface;
8
use Wandu\DI\ServiceProviderInterface;
9
use Wandu\Foundation;
10
use function Wandu\Foundation\config;
11
12
class MonologServiceProvider implements ServiceProviderInterface
13
{
14
    public function register(ContainerInterface $app)
15
    {
16
        $app->closure(Logger::class, function (ContainerInterface $app) {
0 ignored issues
show
Unused Code introduced by
The parameter $app is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
17
            $logger = new Logger('wandu');
18
            if ($path = config('log.path')) {
19
                $logger->pushHandler(new StreamHandler(
20
                    Foundation\path($path)
0 ignored issues
show
Bug introduced by
It seems like \Wandu\Foundation\path($path) targeting Wandu\Foundation\path() can also be of type array; however, Monolog\Handler\StreamHandler::__construct() does only seem to accept resource|string, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
21
                ));
22
            }
23
            return $logger;
24
        });
25
        $app->alias(LoggerInterface::class, Logger::class);
26
        $app->alias('log', Logger::class);
27
    }
28
29
    public function boot(ContainerInterface $app)
30
    {
31
    }
32
}
33