ApiResponse::getHeader()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 3
nc 2
nop 1
crap 2
1
<?php
2
3
namespace Franjid\ApiWrapperBundle\Api;
4
5
use Psr\Http\Message\ResponseInterface;
6
7
class ApiResponse implements ApiResponseInterface
8
{
9
    /** @var ResponseInterface $response */
10
    protected $response;
11
12
    /**
13
     * ApiResponse constructor.
14
     *
15
     * @param ResponseInterface $response
16
     */
17 6
    public function __construct(ResponseInterface $response)
18
    {
19 6
        $this->response = $response;
20 6
    }
21
22
    /**
23
     * {@inheritdoc}
24
     */
25 1
    public function getStatusCode()
26
    {
27 1
        return $this->response->getStatusCode();
28
    }
29
30
    /**
31
     * {@inheritdoc}
32
     */
33 1
    public function getHeaders()
34
    {
35 1
        return $this->response->getHeaders();
36
    }
37
38
    /**
39
     * {@inheritdoc}
40
     */
41 1
    public function getHeader($headerName)
42
    {
43 1
        $headerContent = $this->response->getHeader($headerName);
44
45 1
        return isset($headerContent[0]) ? $headerContent[0] : '';
46
    }
47
48
    /**
49
     * {@inheritdoc}
50
     */
51 1
    public function getBody()
52
    {
53 1
        return $this->response->getBody()->__toString();
54
    }
55
56
    /**
57
     * {@inheritdoc}
58
     */
59 1
    public function isRedirect()
60
    {
61 1
        $statusCode = $this->response->getStatusCode();
62
63 1
        return $statusCode >= 300 && $statusCode < 400;
64
    }
65
}
66