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
Push — master ( f62b15...dc17ca )
by Cees-Jan
10:21 queued 08:46
created

DelayMiddleware::pre()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 2

Importance

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