HeaderLocation   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 0
loc 37
ccs 12
cts 12
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A visit() 0 16 3
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 headers from the response into a result fields
10
 */
11
class HeaderLocation extends AbstractLocation
12
{
13
14
    /**
15
     * Set the name of the location
16
     *
17
     * @param string $locationName
18
     */
19 1
    public function __construct($locationName = 'header')
20
    {
21 1
        parent::__construct($locationName);
22 1
    }
23
24
    /**
25
     * @param ResultInterface   $result
26
     * @param ResponseInterface $response
27
     * @param Parameter         $param
28
     *
29
     * @return ResultInterface
30
     */
31 1
    public function visit(
32
        ResultInterface $result,
33
        ResponseInterface $response,
34
        Parameter $param
35
    ) {
36
        // Retrieving a single header by name
37 1
        $name = $param->getName();
0 ignored issues
show
Bug introduced by
Consider using $param->name. There is an issue with getName() and APC-enabled PHP versions.
Loading history...
38 1
        if ($header = $response->getHeader($param->getWireName())) {
39 1
            if (is_array($header)) {
40 1
                $header = array_shift($header);
41 1
            }
42 1
            $result[$name] = $param->filter($header);
43 1
        }
44
45 1
        return $result;
46
    }
47
}
48