GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

LoggerServiceProvider::provides()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Nip\Logger;
4
5
use Monolog\Logger as Monolog;
6
use Nip\Container\ServiceProviders\Providers\AbstractSignatureServiceProvider;
7
use Nip\Container\ServiceProviders\Providers\BootableServiceProviderInterface;
8
use Nip\Debug\ErrorHandler;
9
use Psr\Log\LoggerInterface as PsrLoggerInterface;
10
11
/**
12
 * Class LoggerServiceProvider
13
 * @package Nip\Logger
14
 */
15
class LoggerServiceProvider extends AbstractSignatureServiceProvider implements BootableServiceProviderInterface
16
{
17
    /**
18
     * @inheritdoc
19
     */
20
    public function register()
21
    {
22
        $this->getContainer()->share('log', function () {
23
            return $this->createLogger();
24
        });
25
26
        $this->getContainer()->share(Monolog::class, $this->createMonolog());
27
    }
28
29
    /**
30
     * Create the logger.
31
     *
32
     * @return Writer
33
     */
34
    public function createLogger()
35
    {
36
        $log = $this->getContainer()->get(Writer::class);
37
38
//        if ($this->app->hasMonologConfigurator()) {
0 ignored issues
show
Unused Code Comprehensibility introduced by
61% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
39
//            call_user_func($this->app->getMonologConfigurator(), $log->getMonolog());
40
//        } else {
41
//            $this->configureHandler($log);
42
//        }
43
        return $log;
44
    }
45
46
    /**
47
     * Create the Monolog.
48
     *
49
     * @return Monolog
50
     */
51
    protected function createMonolog()
52
    {
53
        return new Monolog($this->channel());
54
    }
55
56
    /**
57
     * Get the name of the log "channel".
58
     *
59
     * @return string
60
     */
61
    protected function channel()
62
    {
63
        return 'production';
64
    }
65
66
    public function boot()
67
    {
68
        $logger = $this->getContainer()->get('log');
69
        $logger->init();
70
        $this->getContainer()->get(ErrorHandler::class)->setDefaultLogger($logger);
71
    }
72
73
    /**
74
     * @inheritdoc
75
     */
76
    public function provides()
77
    {
78
        return ['log', PsrLoggerInterface::class];
79
    }
80
}
81