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.

AbstractLogglyLogger::format()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1.0046

Importance

Changes 3
Bugs 0 Features 0
Metric Value
eloc 7
c 3
b 0
f 0
dl 0
loc 12
ccs 5
cts 6
cp 0.8333
rs 10
cc 1
nc 1
nop 3
crap 1.0046
1
<?php
2
3
declare(strict_types=1);
4
5
namespace WyriHaximus\React\PSR3\Loggly;
6
7
use Psr\Log\AbstractLogger;
8
use Stringable;
9
10
use function WyriHaximus\PSR3\checkCorrectLogLevel;
11
use function WyriHaximus\PSR3\normalizeContext;
12
use function WyriHaximus\PSR3\processPlaceHolders;
13
14
abstract class AbstractLogglyLogger extends AbstractLogger
15
{
16
    /**
17
     * @param string       $level
18
     * @param array<mixed> $context
19 26
     *
20
     * @phpstan-ignore-next-line
21 26
     * @psalm-suppress MoreSpecificImplementedParamType
22 24
     */
23 24
    final public function log($level, string|Stringable $message, array $context = []): void // phpcs:disabled
24
    {
25 24
        checkCorrectLogLevel($level);
26
        $this->send(
27
            $this->format($level, $message, $context)
28
        );
29 24
    }
30
31 24
    abstract protected function send(string $data): void;
32 24
33 24
    /**
34 24
     * @param array<mixed> $context
35 24
     */
36 24
    final protected function format(string $level, string|Stringable $message, array $context): string
37 24
    {
38
        $message = (string) $message;
39
        /**
40 24
         * @psalm-suppress MixedArgumentTypeCoercion
41
         */
42
        $context = normalizeContext($context);
43
        $message = processPlaceHolders($message, $context);
44 24
        return \Safe\json_encode([
45
            'level'   => $level,
46
            'message' => $level . ' ' . $message,
47 4
            'context' => $context,
48
        ]);
49 4
    }
50
}
51