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 (#3)
by
unknown
06:44
created

RecordPlugin   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 3
dl 0
loc 37
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A handleRequest() 0 13 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
    public function __construct(NamingStrategyInterface $namingStrategy, RecorderInterface $recorder)
29
    {
30
        $this->namingStrategy = $namingStrategy;
31
        $this->recorder = $recorder;
32
    }
33
34
    /**
35
     * {@inheritdoc}
36
     */
37
    public function handleRequest(RequestInterface $request, callable $next, callable $first): Promise
38
    {
39
        $name = $this->namingStrategy->name($request);
40
41
        return $next($request)->then(function (ResponseInterface $response) use ($name) {
42
            if (!$response->hasHeader(ReplayPlugin::HEADER_NAME)) {
43
                $this->recorder->record($name, $response);
44
                $response = $response->withAddedHeader(static::HEADER_NAME, $name);
45
            }
46
47
            return $response;
48
        });
49
    }
50
}
51