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.
Completed
Push — master ( 010784...210d89 )
by Carsten
08:21 queued 12s
created

TeamsLoggerServiceProvider::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 2
crap 2
1
<?php
2
namespace Germania\Logger;
3
4
use Pimple\Container;
5
use Pimple\ServiceProviderInterface;
6
7
use Monolog\Logger;
8
use Monolog\Formatter\HtmlFormatter;
9
10
class TeamsLoggerServiceProvider implements ServiceProviderInterface
11
{
12
13
    /**
14
     * @var string
15
     */
16
    public $incoming_webook_url;
17
18
    /**
19
     * @var int
20
     */
21
    public $loglevel = Logger::INFO;
22
23
24
    /**
25
     * @param string   $incoming_webook_url [description]
26
     * @param int|null $loglevel            [description]
27
     */
28 8
    public function __construct( string $incoming_webook_url, int $loglevel = null )
29
    {
30 8
        $this->incoming_webook_url = $incoming_webook_url;
31
32 8
        if (!is_null($loglevel)) {
33 8
            $this->loglevel = $loglevel;
34
        }
35 8
    }
36
37
38
    /**
39
     * @param  Container $dic [description]
40
     * @return void
41
     */
42 4
    public function register(Container $dic)
43
    {
44
45
46
        // Make sure there's a 'Monolog.Handlers' service
47 4
        if (!$dic->offsetExists( 'Monolog.Handlers')) :
48
            $dic['Monolog.Handlers'] = function($dic) { return array(); };
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...
49
        endif;
50
51
52
        /**
53
         * @return array
54
         */
55 1
        $dic->extend('Monolog.Handlers', function(array $handlers, $dic) {
56 4
            $handlers[] = $dic['Monolog.Handlers.TeamsHandler'];
57 4
            return $handlers;
58 4
        });
59
60
61
62
        /**
63
         * Send log messages to Microsoft Teams.
64
         *
65
         * @return SlackHandler
66
         */
67 1
        $dic['Monolog.Handlers.TeamsHandler'] = 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...
68 4
            $th = new HtmlFormattedTeamsLogHandler( $this->incoming_webook_url, $this->loglevel);
69 4
            $th->setFormatter( new HtmlFormatter );
70 4
            return $th;
71
        };
72
73
74 4
    }
75
}
76