Completed
Push — master ( 789cc6...743104 )
by David
53:58 queued 32:45
created

HeaderRemovePlugin::handleRequest()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 10
Code Lines 5

Duplication

Lines 10
Ratio 100 %

Code Coverage

Tests 7
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 10
loc 10
ccs 7
cts 7
cp 1
rs 9.4285
cc 3
eloc 5
nc 3
nop 3
crap 3
1
<?php
2
3
namespace Http\Client\Plugin;
4
5
use Psr\Http\Message\RequestInterface;
6
7
/**
8
 * Removes headers from the request.
9
 *
10
 * @author Soufiane Ghzal <[email protected]>
11
 */
12 View Code Duplication
class HeaderRemovePlugin implements Plugin
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
13
{
14
    private $headers = [];
15
16
    /**
17
     * @param array $headers headers to remove from the request
18
     */
19 3
    public function __construct(array $headers)
20
    {
21 3
        $this->headers = $headers;
22 3
    }
23
24
    /**
25
     * {@inheritdoc}
26
     */
27 1
    public function handleRequest(RequestInterface $request, callable $next, callable $first)
28
    {
29 1
        foreach ($this->headers as $header) {
30 1
            if ($request->hasHeader($header)) {
31 1
                $request = $request->withoutHeader($header);
32 1
            }
33 1
        }
34
35 1
        return $next($request);
36
    }
37
}
38