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

NormalizeArrayPlugin::doHandleRequest()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.9
c 0
b 0
f 0
cc 1
nc 1
nop 3
1
<?php
2
3
/**
4
 * This file is part of the bitbucketapi package.
5
 *
6
 * (c) Alexandru G. <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Bitbucket\API\Http\Plugin;
13
14
use Http\Client\Common\Plugin;
15
use Http\Discovery\MessageFactoryDiscovery;
16
use Http\Message\RequestFactory;
17
use Psr\Http\Message\RequestInterface;
18
19
/**
20
 * Transform PHP array to API array
21
 *
22
 * PHP array square brackets does not play nice with remote API,
23
 * which expects just the key name, without brackets.
24
 *
25
 * Transforms: foo[0]=xxx&foo[1]=yyy" to "foo=xxx&foo=yyy"
26
 *
27
 * @author  Alexandru G.    <[email protected]>
28
 */
29
class NormalizeArrayPlugin implements Plugin
30
{
31
    use Plugin\VersionBridgePlugin;
32
33
    /**
34
     * {@inheritDoc}
35
     */
36
    protected function doHandleRequest(RequestInterface $request, callable $next, callable $first)
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
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...
37
    {
38
        // Transform: "foo[0]=xxx&foo[1]=yyy" to "foo=xxx&foo=yyy"
39
        $request = $request->withUri(
40
            $request->getUri()->withQuery(
41
                preg_replace('/%5B(?:[0-9]|[1-9][0-9]+)%5D=/', '=', $request->getUri()->getQuery())
42
            )
43
        );
44
45
        return $next($request);
46
    }
47
}
48