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.

BrowserConsoleLoggerServiceProvider::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
namespace Germania\Logger;
3
4
use Pimple\Container;
5
use Pimple\ServiceProviderInterface;
6
7
use Monolog\Logger;
8
use Monolog\Handler\BrowserConsoleHandler;
9
10
class BrowserConsoleLoggerServiceProvider implements ServiceProviderInterface
11
{
12
13
14
    /**
15
     * @var int
16
     */
17
    public $loglevel = Logger::INFO;
18
19
20
    /**
21
     * @param int|null $loglevel Optional: Monolog Loglevel constant. Set to `null` to disable browser logging entirely.
22
     */
23 2
    public function __construct(int $loglevel = null)
24
    {
25 2
        $this->loglevel = $loglevel;
26 2
    }
27
28
29
    /**
30
     * @param  Container $dic [description]
31
     * @return void
32
     */
33 2 View Code Duplication
    public function register(Container $dic)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
34
    {
35
        // Do nothing when no loglevel is set
36 2
        if (empty($this->loglevel)) {
37
            return;
38
        }
39
40
        // Make sure there's a 'Monolog.Handlers' service
41 2
        if (!$dic->offsetExists('Monolog.Handlers')) :
42 2
            $dic['Monolog.Handlers'] = function ($dic) {
0 ignored issues
show
Unused Code introduced by
The parameter $dic 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...
43
                return array();
44
            };
45
        endif;
46
47
48
        /**
49
         * @return array
50
         */
51 2
        $dic->extend('Monolog.Handlers', function (array $handlers, $dic) {
52
            $handlers[] = $dic['Monolog.Handlers.BrowserConsoleHandler'];
53
            return $handlers;
54 2
        });
55
56
57
58
        /**
59
         * @return BrowserConsoleHandler
60
         */
61 2
        $dic['Monolog.Handlers.BrowserConsoleHandler'] = function ($dic) {
0 ignored issues
show
Unused Code introduced by
The parameter $dic 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...
62 2
            $th = new BrowserConsoleHandler($this->loglevel);
63 2
            return $th;
64
        };
65 2
    }
66
}
67