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.

RecordPlugin   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 3
dl 0
loc 37
ccs 11
cts 11
cp 1
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 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
        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