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::__invoke()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 3.0416

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 11
ccs 5
cts 6
cp 0.8333
rs 10
cc 3
nc 3
nop 1
crap 3.0416
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