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
02:19
created

ReplayPlugin   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 34
c 0
b 0
f 0
wmc 3
lcom 1
cbo 3
ccs 9
cts 9
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A handleRequest() 0 10 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\PlayerInterface;
10
use Http\Promise\FulfilledPromise;
11
use Http\Promise\Promise;
12
use Psr\Http\Message\RequestInterface;
13
14
final class ReplayPlugin implements Plugin
15
{
16
    const HEADER_NAME = 'X-VCR-REPLAYED';
17
18
    /**
19
     * @var NamingStrategyInterface
20
     */
21
    private $namingStrategy;
22
23
    /**
24
     * @var PlayerInterface
25
     */
26
    private $player;
27
28 1
    public function __construct(NamingStrategyInterface $namingStrategy, PlayerInterface $player)
29
    {
30 1
        $this->namingStrategy = $namingStrategy;
31 1
        $this->player = $player;
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
        if ($response = $this->player->replay($name)) {
42 1
            return new FulfilledPromise($response->withAddedHeader(static::HEADER_NAME, $name));
43
        }
44
45 1
        return $next($request);
46
    }
47
}
48