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::getMessageFactory()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 3

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 7
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
cc 3
nc 2
nop 1
crap 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