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.

FormattedPsrHandler::write()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2.0116

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 14
ccs 6
cts 7
cp 0.8571
rs 10
cc 2
nc 2
nop 1
crap 2.0116
1
<?php
2
3
declare(strict_types=1);
4
5
namespace WyriHaximus\Monolog\FormattedPsrHandler;
6
7
use Monolog\Handler\AbstractProcessingHandler;
8
use Monolog\Level;
9
use Monolog\LogRecord;
10
use Psr\Log\LoggerInterface;
11
12
use function strtolower;
13 2
use function WyriHaximus\PSR3\formatValue;
14
15 2
final class FormattedPsrHandler extends AbstractProcessingHandler
16
{
17 2
    /** @phpstan-ignore-next-line */
18 2
    public function __construct(protected LoggerInterface $logger, int|string|Level $level = Level::Debug, bool $bubble = true)
19
    {
20
        /** @psalm-suppress ArgumentTypeCoercion */
21
        parent::__construct($level, $bubble);
22
    }
23 2
24
    protected function write(LogRecord $record): void
25 2
    {
26
        /** @psalm-suppress InvalidArgument */
27
        if (! $this->isHandling($record)) {
28
            // @codeCoverageIgnoreStart
29 2
            return; // This is tested in FormattedPsrHandlerTest::notHandled but not picked up by PHPUnit as covered
30 2
31 2
            // @codeCoverageIgnoreEnd
32 2
        }
33
34 2
        $this->logger->log(
35
            strtolower($record->level->name),
0 ignored issues
show
Bug introduced by
The property name does not seem to exist on Monolog\Level.
Loading history...
36
            formatValue($record->formatted ?? $record->message),
37
            $record->context,
38
        );
39
    }
40
}
41