ReasonPhraseLocation::visit()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11

Duplication

Lines 11
Ratio 100 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
dl 11
loc 11
ccs 5
cts 5
cp 1
rs 9.9
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 reason phrase of a response into a result field
10
 */
11 View Code Duplication
class ReasonPhraseLocation 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 = 'reasonPhrase')
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(
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 1
            $response->getReasonPhrase()
37 1
        );
38
39 1
        return $result;
40
    }
41
}
42