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.

PersonalAuthorizationHeaderMiddleware   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 3
dl 0
loc 31
c 0
b 0
f 0
ccs 9
cts 9
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A pre() 0 20 3
1
<?php declare(strict_types=1);
2
3
namespace ApiClients\Middleware\PersonalAuthorization;
4
5
use ApiClients\Foundation\Middleware\ErrorTrait;
6
use ApiClients\Foundation\Middleware\MiddlewareInterface;
7
use ApiClients\Foundation\Middleware\PostTrait;
8
use Psr\Http\Message\RequestInterface;
9
use React\Promise\CancellablePromiseInterface;
10
use function React\Promise\resolve;
11
12
/**
13
 * Middleware that adds the authorization header in the token format.
14
 */
15
class PersonalAuthorizationHeaderMiddleware implements MiddlewareInterface
16
{
17
    use PostTrait;
18
    use ErrorTrait;
19
20
    /**
21
     * @param  RequestInterface            $request
22
     * @param  array                       $options
23
     * @return CancellablePromiseInterface
24
     */
25 4
    public function pre(
26
        RequestInterface $request,
27
        string $transactionId,
28
        array $options = []
29
    ): CancellablePromiseInterface {
30 4
        if (!isset($options[self::class][Options::TOKEN])) {
31 2
            return resolve($request);
32
        }
33
34 2
        if (empty($options[self::class][Options::TOKEN])) {
35 1
            return resolve($request);
36
        }
37
38 1
        return resolve(
39 1
            $request->withAddedHeader(
40 1
                'Authorization',
41 1
                'Personal ' . $options[self::class][Options::TOKEN]
42
            )
43
        );
44
    }
45
}
46