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 ( ae671f...7094e6 )
by David
02:14
created

RecordPlugin::handleRequest()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 13
ccs 8
cts 8
cp 1
rs 9.8333
c 0
b 0
f 0
cc 2
nc 1
nop 3
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Http\Client\Plugin\Vcr;
6
7
use Http\Client\Common\Plugin;
8
use Http\Client\Plugin\Vcr\NamingStrategy\NamingStrategyInterface;
9
use Http\Client\Plugin\Vcr\Recorder\RecorderInterface;
10
use Http\Promise\Promise;
11
use Psr\Http\Message\RequestInterface;
12
use Psr\Http\Message\ResponseInterface;
13
14
final class RecordPlugin implements Plugin
15
{
16
    const HEADER_NAME = 'X-VCR-RECORD';
17
18
    /**
19
     * @var NamingStrategyInterface
20
     */
21
    private $namingStrategy;
22
23
    /**
24
     * @var RecorderInterface
25
     */
26
    private $recorder;
27
28 1
    public function __construct(NamingStrategyInterface $namingStrategy, RecorderInterface $recorder)
29
    {
30 1
        $this->namingStrategy = $namingStrategy;
31 1
        $this->recorder = $recorder;
32 1
    }
33
34
    /**
35
     * {@inheritdoc}
36
     */
37 1
    public function handleRequest(RequestInterface $request, callable $next, callable $first): Promise
38
    {
39 1
        $name = $this->namingStrategy->name($request);
40
41 1
        return $next($request)->then(function (ResponseInterface $response) use ($name) {
42 1
            if (!$response->hasHeader(ReplayPlugin::HEADER_NAME)) {
43 1
                $this->recorder->record($name, $response);
44 1
                $response = $response->withAddedHeader(static::HEADER_NAME, $name);
45
            }
46
47 1
            return $response;
48 1
        });
49
    }
50
}
51