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.
Passed
Pull Request — master (#17)
by
unknown
01:34
created

WithHeadersMiddleware   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 6
c 0
b 0
f 0
dl 0
loc 20
ccs 0
cts 11
cp 0
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A __invoke() 0 8 2
1
<?php declare(strict_types=1);
2
3
namespace WyriHaximus\React\Http\Middleware;
4
5
use Psr\Http\Message\ResponseInterface;
6
use Psr\Http\Message\ServerRequestInterface;
7
use function React\Promise\resolve;
8
9
final class WithHeadersMiddleware
10
{
11
    private $headers = [];
12
13
    /**
14
     * @param array $headers
15
     */
16
    public function __construct(array $headers)
17
    {
18
        $this->headers = $headers;
19
    }
20
21
    public function __invoke(ServerRequestInterface $request, callable $next)
22
    {
23
        return resolve($next($request))->then(function (ResponseInterface $response) {
24
            foreach ($this->headers as $header => $value) {
25
                $response = $response->withHeader($header, $value);
26
            }
27
28
            return resolve($response);
29
        });
30
    }
31
}
32