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.

CopyProcessor::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 2
crap 1
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_merge_recursive;
11
use function explode;
12
use function igorw\assoc_in;
13
use function igorw\get_in;
14
15
final class CopyProcessor implements ProcessorInterface
16
{
17
    /** @var array<string> */
18
    private array $from;
19
20
    /** @var array<string> */
21
    private array $to;
22
23
    public function __construct(string $from, string $to)
24 3
    {
25
        $this->from = explode('.', $from);
26 3
        $this->to   = explode('.', $to);
27 3
    }
28 3
29
    public function __invoke(LogRecord $record): LogRecord
30
    {
31
        $value = get_in($record->toArray(), $this->from);
32
        if ($value !== null) {
33
            $record = $record->with(...array_merge_recursive(assoc_in([], $this->to, $value), ['context' => $record->context, 'extra' => $record->extra]));
34 3
        }
35
36 3
        return $record;
37 3
    }
38
}
39