StatusCodeLocation::visit()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9

Duplication

Lines 9
Ratio 100 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 9
loc 9
ccs 3
cts 3
cp 1
rs 9.9666
c 0
b 0
f 0
cc 1
nc 1
nop 3
crap 1
1
<?php
2
namespace GuzzleHttp\Command\Guzzle\ResponseLocation;
3
4
use GuzzleHttp\Command\Guzzle\Parameter;
5
use GuzzleHttp\Command\ResultInterface;
6
use Psr\Http\Message\ResponseInterface;
7
8
/**
9
 * Extracts the status code of a response into a result field
10
 */
11 View Code Duplication
class StatusCodeLocation extends AbstractLocation
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...
12
{
13
14
    /**
15
     * Set the name of the location
16
     *
17
     * @param string $locationName
18
     */
19 1
    public function __construct($locationName = 'statusCode')
20
    {
21 1
        parent::__construct($locationName);
22 1
    }
23
24
    /**
25
     * @param ResultInterface $result
26
     * @param ResponseInterface $response
27
     * @param Parameter $param
28
     * @return ResultInterface
29
     */
30 1
    public function visit(
31
        ResultInterface $result,
32
        ResponseInterface $response,
33
        Parameter $param
34
    ) {
35 1
        $result[$param->getName()] = $param->filter($response->getStatusCode());
0 ignored issues
show
Bug introduced by
Consider using $param->name. There is an issue with getName() and APC-enabled PHP versions.
Loading history...
36
37 1
        return $result;
38
    }
39
}
40