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.
Completed
Push — master ( 1ef8bd...74d50b )
by Cees-Jan
04:19
created

AbstractLogglyLogger::formatValue()   B

Complexity

Conditions 6
Paths 3

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 10.5

Importance

Changes 0
Metric Value
dl 0
loc 12
ccs 3
cts 6
cp 0.5
rs 8.8571
c 0
b 0
f 0
cc 6
eloc 6
nc 3
nop 1
crap 10.5
1
<?php declare(strict_types=1);
2
3
namespace WyriHaximus\React\PSR3\Loggly;
4
5
use Psr\Log\AbstractLogger;
6
use Psr\Log\InvalidArgumentException;
7
use function WyriHaximus\PSR3\checkCorrectLogLevel;
8
use function WyriHaximus\PSR3\normalizeContext;
9
use function WyriHaximus\PSR3\processPlaceHolders;
10
11
abstract class AbstractLogglyLogger extends AbstractLogger
12
{
13
    abstract protected function send(string $data);
14
15
    public function log($level, $message, array $context = [])
16
    {
17
        checkCorrectLogLevel($level);
18
        $data = $this->format($level, $message, $context);
19
        $this->send($data);
20
    }
21
22
    protected function format($level, $message, array $context): string
23
    {
24
        $message = (string)$message;
25
        $context = normalizeContext($context);
26
        $message = processPlaceHolders($message, $context);
27
        $json = json_encode([
28
            'level'   => $level,
29
            'message' => $level . ' ' . $message,
30
            'context' => $context,
31
        ]);
32
33
        if ($json === false) {
34
            throw new InvalidArgumentException(json_last_error_msg());
35
        }
36
37
        return $json;
38
    }
39
}
40