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.

ContextLogger::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 3
dl 0
loc 10
ccs 7
cts 7
cp 1
crap 2
rs 9.9332
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
3
namespace WyriHaximus\PSR3\ContextLogger;
4
5
use Psr\Log\AbstractLogger;
6
use Psr\Log\LoggerInterface;
7
8
final class ContextLogger extends AbstractLogger
9
{
10
    /**
11
     * @var LoggerInterface
12
     */
13
    private $logger;
14
15
    /**
16
     * @var array
17
     */
18
    private $context;
19
20
    /**
21
     * @var string
22
     */
23
    private $prefix;
24
25
    /**
26
     * @param LoggerInterface $logger
27
     * @param array           $context
28
     * @param string          $prefix
29
     */
30 16
    public function __construct(LoggerInterface $logger, array $context, string $prefix = null)
31
    {
32 16
        $this->logger = $logger;
33 16
        $this->context = $context;
34
35 16
        if ($prefix !== null) {
36 15
            $prefix = '[' . $prefix . '] ';
37
        }
38 16
        $this->prefix = $prefix;
39 16
    }
40
41 15
    public function log($level, $message, array $context = []): void
42
    {
43 15
        $this->logger->log($level, $this->prefix . $message, $this->context + $context);
44 14
    }
45
}
46