Notification Setup Error

We have detected an error in your notification set-up (Event-ID dab39dc24f564ec7bd4628d1305fd03c). Currently, we cannot inform you about inspection progress. Please check that the user 557058:bca11929-8c2d-43f2-8a82-c5416880d395 still has access to your repository or update the API account.

Completed
Push — develop ( a55da1...39a772 )
by
unknown
27:43 queued 12:35
created

ApiVersionPlugin::doHandleRequest()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.9666
c 0
b 0
f 0
cc 2
nc 2
nop 3
1
<?php
2
3
namespace Bitbucket\API\Http\Plugin;
4
5
use Http\Client\Common\Plugin;
6
use Http\Promise\Promise;
7
use Psr\Http\Message\RequestInterface;
8
9
class ApiVersionPlugin implements Plugin
10
{
11
    use Plugin\VersionBridgePlugin;
12
13
    /** @var string */
14
    private $version;
15
16
    /**
17
     * @param string $version
18
     */
19
    public function __construct($version)
20
    {
21
        $this->version = $version;
22
    }
23
24
    /**
25
     * @param RequestInterface $request
26
     * @param callable $next Next middleware in the chain, the request is passed as the first argument
27
     * @param callable $first First middleware in the chain, used to to restart a request
28
     *
29
     * @return Promise Resolves a PSR-7 Response or fails with an Http\Client\Exception (The same as HttpAsyncClient).
30
     */
31
    protected function doHandleRequest(RequestInterface $request, callable $next, callable $first)
0 ignored issues
show
Unused Code introduced by
The parameter $first is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
32
    {
33
        $uri = $request->getUri();
34
        if (strpos($uri->getPath(), '/' . $this->version) !== 0) {
35
            $request = $request->withUri($uri->withPath('/' . $this->version . $uri->getPath()));
36
        }
37
38
        return $next($request);
39
    }
40
}
41