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.

FileLoggerServiceProvider   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 79
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 95.65%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 2
dl 0
loc 79
ccs 22
cts 23
cp 0.9565
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 12 3
A register() 0 36 3
1
<?php
2
namespace Germania\Logger;
3
4
use Pimple\Container;
5
use Pimple\ServiceProviderInterface;
6
7
use Monolog\Logger;
8
use Monolog\Handler\RotatingFileHandler;
9
10
class FileLoggerServiceProvider implements ServiceProviderInterface
11
{
12
13
    /**
14
     * @var string
15
     */
16
    public $logfile = "php://stderr";
17
18
    /**
19
     * @var int
20
     */
21
    public $max_files = 30;
22
23
    /**
24
     * @var int
25
     */
26
    public $loglevel = Logger::DEBUG;
27
28
29
    /**
30
     * @param string|null $logfile   Logfile path
31
     * @param int|null    $max_files Maximum number of logfiles
32
     * @param int|null    $loglevel  Monolog Loglevel constant
33
     */
34 6
    public function __construct(string $logfile = null, int $max_files = null, int $loglevel = null)
35
    {
36 6
        $this->logfile = $logfile;
37
38 6
        if (!is_null($max_files)) {
39 6
            $this->max_files = $max_files;
40
        }
41
42 6
        if (!is_null($loglevel)) {
43 6
            $this->loglevel = $loglevel;
44
        }
45 6
    }
46
47
48
    /**
49
     * @param  Container $dic [description]
50
     * @return void
51
     */
52 4
    public function register(Container $dic)
53
    {
54
        // Do nothing when no logfile is set
55 4
        if (empty($this->logfile)) {
56
            return;
57
        }
58
59
60
        // Make sure there's a 'Monolog.Handlers' service
61 4
        if (!$dic->offsetExists('Monolog.Handlers')) :
62 4
            $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...
63 2
                return array();
64
            };
65
        endif;
66
67
68
        /**
69
         * @return array
70
         */
71 4
        $dic->extend('Monolog.Handlers', function (array $handlers, $dic) {
72 2
            $handlers[] = $dic['Monolog.Handlers.RotatingFileHandler'];
73 2
            return $handlers;
74 4
        });
75
76
77
        /**
78
         * @return RotatingFileHandler
79
         */
80 4
        $dic['Monolog.Handlers.RotatingFileHandler'] = 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...
81 4
            $logfile   = $this->logfile;
82 4
            $max_files = $this->max_files;
83 4
            $loglevel  = $this->loglevel;
84
85 4
            return new RotatingFileHandler($logfile, $max_files, $loglevel);
86
        };
87 4
    }
88
}
89