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
09:25
created

ReplayPlugin::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 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
    public function __construct(NamingStrategyInterface $namingStrategy, PlayerInterface $player)
29
    {
30
        $this->namingStrategy = $namingStrategy;
31
        $this->player = $player;
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
        if ($response = $this->player->replay($name)) {
42
            return new FulfilledPromise($response->withAddedHeader(static::HEADER_NAME, $name));
43
        }
44
45
        return $next($request);
46
    }
47
}
48