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
Pull Request — master (#1)
by Cees-Jan
09:51
created

DelayMiddleware::priority()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php declare(strict_types=1);
2
3
namespace ApiClients\Middleware\Delay;
4
5
use ApiClients\Foundation\Middleware\Annotation\Second;
6
use ApiClients\Foundation\Middleware\ErrorTrait;
7
use ApiClients\Foundation\Middleware\MiddlewareInterface;
8
use ApiClients\Foundation\Middleware\PostTrait;
9
use Psr\Http\Message\RequestInterface;
10
use React\EventLoop\LoopInterface;
11
use React\Promise\CancellablePromiseInterface;
12
use function React\Promise\resolve;
13
use function WyriHaximus\React\timedPromise;
14
15
final class DelayMiddleware implements MiddlewareInterface
16
{
17
    use PostTrait;
18
    use ErrorTrait;
19
20
    /**
21
     * @var LoopInterface
22
     */
23
    private $loop;
24
25
    /**
26
     * DelayMiddleware constructor.
27
     * @param LoopInterface $loop
28
     */
29 2
    public function __construct(LoopInterface $loop)
30
    {
31 2
        $this->loop = $loop;
32 2
    }
33
34
    /**
35
     * @param RequestInterface $request
36
     * @param array $options
37
     * @return CancellablePromiseInterface
38
     *
39
     * @Second()
40
     */
41 2
    public function pre(
42
        RequestInterface $request,
43
        string $transactionId,
44
        array $options = []
45
    ): CancellablePromiseInterface {
46 2
        if (!isset($options[self::class][Options::DELAY])) {
47 1
            return resolve($request);
48
        }
49
50 1
        return timedPromise(
51 1
            $this->loop,
52 1
            $options[self::class][Options::DELAY],
53 1
            $request
54 1
        )->then(function (RequestInterface $request) {
55 1
            return resolve($request);
56 1
        });
57
    }
58
}
59