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.

ToContextProcessor::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 0
c 1
b 0
f 0
dl 0
loc 2
ccs 0
cts 0
cp 0
rs 10
cc 1
nc 1
nop 1
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace WyriHaximus\Monolog\Processors;
6
7
use Monolog\LogRecord;
8
use Monolog\Processor\ProcessorInterface;
9
10
use function array_key_exists;
11
12
final class ToContextProcessor implements ProcessorInterface
13
{
14
    /**
15 3
     * @param array<string> $keys
16
     *
17 3
     * @phpstan-ignore-next-line
18 3
     */
19
    public function __construct(private array $keys = ['channel', 'extra', 'datetime'])
20
    {
21
    }
22
23
    public function __invoke(LogRecord $record): LogRecord
24 3
    {
25
        foreach ($this->keys as $key) {
26 3
            if (! array_key_exists($key, $record->toArray())) {
27 3
                continue;
28
            }
29
30 3
            $record = $record->with(context: [$key => $record->toArray()[$key]] + $record->toArray()['context']);
31
        }
32
33 3
        return $record;
34
    }
35
}
36