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 (#2)
by Cees-Jan
07:27
created

Middleware::pre()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 2
cts 2
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 2
crap 1
1
<?php declare(strict_types=1);
2
3
namespace ApiClients\Middleware\Skeleton;
4
5
use ApiClients\Foundation\Middleware\MiddlewareInterface;
6
use ApiClients\Foundation\Middleware\Priority;
7
use Psr\Http\Message\RequestInterface;
8
use Psr\Http\Message\ResponseInterface;
9
use React\Promise\CancellablePromiseInterface;
10
use Throwable;
11
use function React\Promise\reject;
12
use function React\Promise\resolve;
13
14
final class Middleware implements MiddlewareInterface
15
{
16
    /**
17
     * Return the processed $request via a fulfilled promise.
18
     * When implementing cache or other feature that returns a response, do it with a rejected promise.
19
     * If neither is possible, e.g. on some kind of failure, resolve the unaltered request.
20
     *
21
     * @param  RequestInterface            $request
22
     * @param  array                       $options
23
     * @return CancellablePromiseInterface
24
     */
25 2
    public function pre(RequestInterface $request, array $options = []): CancellablePromiseInterface
26
    {
27
        // TODO: Implement pre() method or add PreTrait and remove this method
28 2
        return resolve($request);
29
    }
30
31
    /**
32
     * Return the processed $response via a promise.
33
     *
34
     * @param  ResponseInterface           $response
35
     * @param  array                       $options
36
     * @return CancellablePromiseInterface
37
     */
38 1
    public function post(ResponseInterface $response, array $options = []): CancellablePromiseInterface
39
    {
40
        // TODO: Implement post() method. Or add PostTrait and remove this method
41 1
        return resolve($response);
42
    }
43
44
    /**
45
     * Deal with possible errors that occurred during request/response events.
46
     *
47
     * @param  Throwable                   $throwable
48
     * @param  array                       $options
49
     * @return CancellablePromiseInterface
50
     */
51 1
    public function error(Throwable $throwable, array $options = []): CancellablePromiseInterface
52
    {
53
        // TODO: Implement error() method. Or add ErrorTrait and remove this method
54 1
        return reject($throwable);
55
    }
56
57
    /**
58
     * Priority ranging from 0 to 1000. Where 1000 will be executed first on `pre` and 0 last on `pre`.
59
     * For `post` the order is reversed.
60
     *
61
     * @return int
62
     */
63
    public function priority(): int
64
    {
65
        // TODO: Implement priority() method or add DefaultPriorityTrait and remove this method
66
        return Priority::DEFAULT;
67
    }
68
}
69