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 ( 9c2e1a...1f7860 )
by Cees-Jan
15:23 queued 12:04
created

AbstractLogglyLogger   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Test Coverage

Coverage 40.74%

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 5
dl 0
loc 52
ccs 11
cts 27
cp 0.4074
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
send() 0 1 ?
A createHttpClient() 0 21 2
A log() 0 7 1
A format() 0 17 2
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 React\Dns\Resolver\Factory as ResolverFactory;
8
use React\EventLoop\LoopInterface;
9
use React\HttpClient\Client;
10
use React\HttpClient\Factory as HttpClientFactory;
11
use React\Socket\Connector;
12
use function WyriHaximus\PSR3\checkCorrectLogLevel;
13
use function WyriHaximus\PSR3\normalizeContextWithFormatValue;
14
use function WyriHaximus\PSR3\processPlaceHolders;
15
16
abstract class AbstractLogglyLogger extends AbstractLogger
17
{
18 2
    public function log($level, $message, array $context = []): void
19
    {
20 2
        checkCorrectLogLevel($level);
21
        $this->send(
22
            $this->format($level, $message, $context)
23
        );
24
    }
25
26
    abstract protected function send(string $data);
27
28
    protected function format($level, $message, array $context): string
29
    {
30
        $message = (string)$message;
31
        $context = normalizeContextWithFormatValue($context);
32
        $message = processPlaceHolders($message, $context);
33
        $json = \json_encode([
34
            'level'   => $level,
35
            'message' => $level . ' ' . $message,
36
            'context' => $context,
37
        ]);
38
39
        if ($json === false) {
40
            throw new InvalidArgumentException(\json_last_error_msg());
41
        }
42
43
        return $json;
44
    }
45
46 4
    protected static function createHttpClient(LoopInterface $loop): Client
47
    {
48 4
        $resolverFactory = new ResolverFactory();
49 4
        $resolver = $resolverFactory->createCached('8.8.8.8', $loop);
50
51 4
        if (\class_exists(HttpClientFactory::class)) {
52
            $factory = new HttpClientFactory();
53
54
            return $factory->create($loop, $resolver);
55
        }
56
57 4
        return new Client(
58 4
            $loop,
59 4
            new Connector(
60 4
                $loop,
61
                [
62 4
                    'dns' => $resolver,
63
                ]
64
            )
65
        );
66
    }
67
}
68