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.

HttpExceptionsMiddleware::error()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 3
dl 0
loc 11
ccs 4
cts 4
cp 1
crap 2
rs 9.9
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
3
namespace ApiClients\Middleware\HttpExceptions;
4
5
use ApiClients\Foundation\Middleware\Annotation\ThirdLast;
6
use ApiClients\Foundation\Middleware\MiddlewareInterface;
7
use ApiClients\Foundation\Middleware\PostTrait;
8
use ApiClients\Foundation\Middleware\PreTrait;
9
use ApiClients\Tools\Psr7\HttpStatusExceptions\ExceptionFactory;
10
use Clue\React\Buzz\Message\ResponseException;
11
use React\Promise\CancellablePromiseInterface;
12
use Throwable;
13
use function React\Promise\reject;
14
15
final class HttpExceptionsMiddleware implements MiddlewareInterface
16
{
17
    use PreTrait;
18
    use PostTrait;
19
20
    /**
21
     * When $throwable is a ResponseException this method will turn it into a
22
     * HTTP status code specific exception.
23
     *
24
     * @param Throwable $throwable
25
     * @param array $options
26
     * @return CancellablePromiseInterface
27
     *
28
     * @ThirdLast()
29
     */
30 72
    public function error(
31
        Throwable $throwable,
32
        string $transactionId,
33
        array $options = []
34
    ): CancellablePromiseInterface {
35 72
        if (!($throwable instanceof ResponseException)) {
36 1
            return reject($throwable);
37
        }
38
39 71
        return reject(ExceptionFactory::create($throwable->getResponse(), $throwable));
40
    }
41
}
42