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   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 26
ccs 4
cts 4
cp 1
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 2
A log() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace WyriHaximus\PSR3\ContextLogger;
6
7
use Psr\Log\AbstractLogger;
8
use Psr\Log\LoggerInterface;
9
10
final class ContextLogger extends AbstractLogger
11
{
12
    private readonly string $prefix;
13
14
    /**
15
     * @param array<mixed> $context
16
     *
17
     * @phpstan-ignore-next-line
18
     */
19
    public function __construct(private readonly LoggerInterface $logger, private readonly array $context, string $prefix = '')
20
    {
21
        if ($prefix !== '') {
22
            $prefix = '[' . $prefix . '] ';
23
        }
24
25
        $this->prefix = $prefix;
0 ignored issues
show
Bug introduced by
The property prefix is declared read-only in WyriHaximus\PSR3\ContextLogger\ContextLogger.
Loading history...
26
    }
27
28
    /**
29
     * @inheritDoc
30 16
     * @phpstan-ignore-next-line
31
     */
32 16
    public function log($level, $message, array $context = []): void
33 16
    {
34
        /** @phpstan-ignore psr3.interpolated */
35 16
        $this->logger->log($level, $this->prefix . $message, $this->context + $context);
36 15
    }
37
}
38