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   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 85.71%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 0
loc 46
ccs 12
cts 14
cp 0.8571
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A pre() 0 14 2
A priority() 0 4 1
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