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   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Test Coverage

Coverage 94.12%

Importance

Changes 7
Bugs 0 Features 0
Metric Value
wmc 2
eloc 11
c 7
b 0
f 0
dl 0
loc 34
ccs 16
cts 17
cp 0.9412
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A format() 0 12 1
A log() 0 5 1
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