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.
Test Failed
Branch master (e50042)
by Harald
05:40 queued 11s
created

Caller   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 8
eloc 14
dl 0
loc 49
ccs 13
cts 13
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A request() 0 8 2
A getHttpClient() 0 7 3
A getMessageFactory() 0 7 3
1
<?php
2
3
namespace Bokbasen\ApiClient;
4
5
use Bokbasen\ApiClient\Exceptions\BokbasenApiClientException;
6
use Http\Client\HttpClient;
7
use Http\Discovery\HttpClientDiscovery;
8
use Http\Discovery\MessageFactoryDiscovery;
9
use Http\Message\MessageFactory;
10
use Psr\Http\Message\ResponseInterface;
11
use Psr\Http\Message\StreamInterface;
12
use Psr\Http\Message\UriInterface;
13
14
class Caller
15
{
16
    /**
17
     * @var HttpClient
18
     */
19
    private $httpClient;
20
21
    /**
22
     * @var MessageFactory
23
     */
24
    private $messageFactory;
25
26
    /**
27
     * @param string                               $method
28
     * @param string|UriInterface                  $url
29
     * @param array                                $headers
30
     * @param resource|string|StreamInterface|null $body
31
     *
32
     * @return ResponseInterface
33
     *
34
     * @throws BokbasenApiClientException
35
     */
36 2
    public function request(string $method, $url, array $headers = [], $body = null): ResponseInterface
37
    {
38
        try {
39 2
            return $this->getHttpClient()->sendRequest(
40 2
                $this->getMessageFactory()->createRequest($method, $url, $headers, $body)
41
            );
42 2
        } catch (\Http\Client\Exception | \Exception $e) {
43 2
            throw new BokbasenApiClientException($e->getMessage(), $e->getCode(), $e);
44
        }
45
    }
46
47 2
    protected function getHttpClient(HttpClient $httpClient = null): HttpClient
48
    {
49 2
        if (!$this->httpClient) {
50 2
            $this->httpClient = $httpClient ?: HttpClientDiscovery::find();
51
        }
52
53 2
        return $this->httpClient;
54
    }
55
56 2
    protected function getMessageFactory(MessageFactory $messageFactory = null): MessageFactory
57
    {
58 2
        if (!$this->messageFactory) {
59 2
            $this->messageFactory = $messageFactory ?: MessageFactoryDiscovery::find();
60
        }
61
62 2
        return $this->messageFactory;
63
    }
64
}
65