Test Failed
Push — master ( 1c53d0...36f19e )
by Vsevolods
11:19
created

Response::getContent()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
rs 10
ccs 2
cts 2
cp 1
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php declare(strict_types = 1);
2
3
namespace Venta\Http;
4
5
use Psr\Http\Message\ResponseInterface;
6
use Psr\Http\Message\StreamInterface;
7
use Venta\Contracts\Http\Response as ResponseContract;
8
9
/**
10
 * Class Response
11
 *
12
 * @package Venta\Http
13
 */
14
class Response implements ResponseContract
15
{
16
17
    /**
18
     * @var ResponseInterface
19
     */
20
    private $psrResponse;
21
22
    /**
23
     * Response constructor.
24
     *
25
     * @param ResponseInterface $psrResponse
26
     */
27 9
    public function __construct(ResponseInterface $psrResponse)
28
    {
29 9
        $this->psrResponse = $psrResponse;
30 9
    }
31
32
    /**
33
     * @inheritDoc
34
     */
35 1
    public function append(string $body): ResponseContract
36
    {
37 1
        $this->psrResponse->getBody()->write($body);
38
39 1
        return $this;
40
    }
41
42
    /**
43
     * @inheritDoc
44
     */
45
    public function getBody()
46
    {
47
        return $this->psrResponse->getBody();
48
    }
49
50
    /**
51
     * @inheritDoc
52
     */
53 2
    public function content(): string
54
    {
55 2
        return (string)$this->psrResponse->getBody();
56
    }
57
58
    /**
59
     * @inheritDoc
60
     */
61 1
    public function getHeader($name)
62
    {
63 1
        return $this->psrResponse->getHeader($name);
64
    }
65
66
    /**
67
     * @inheritDoc
68
     */
69 1
    public function getHeaderLine($name)
70
    {
71 1
        return $this->psrResponse->getHeaderLine($name);
72
    }
73
74
    /**
75
     * @inheritDoc
76
     */
77 1
    public function getHeaders()
78
    {
79 1
        return $this->psrResponse->getHeaders();
80
    }
81
82
    /**
83
     * @inheritDoc
84
     */
85
    public function getProtocolVersion()
86
    {
87
        return $this->psrResponse->getProtocolVersion();
88
    }
89
90
    /**
91
     * @inheritDoc
92
     */
93
    public function getReasonPhrase()
94
    {
95
        return $this->psrResponse->getReasonPhrase();
96
    }
97
98
    /**
99
     * @inheritDoc
100
     */
101 4
    public function getStatusCode()
102
    {
103 4
        return $this->psrResponse->getStatusCode();
104
    }
105
106
    /**
107
     * @inheritDoc
108
     */
109 1
    public function hasHeader($name)
110
    {
111 1
        return $this->psrResponse->hasHeader($name);
112
    }
113
114
    /**
115
     * @inheritDoc
116
     */
117
    public function withAddedHeader($name, $value)
118
    {
119
        return new self($this->psrResponse->withAddedHeader($name, $value));
120
    }
121
122
    /**
123
     * @inheritDoc
124
     */
125
    public function withBody(StreamInterface $body)
126
    {
127
        return new self($this->psrResponse->withBody($body));
128
    }
129
130
    /**
131
     * @inheritDoc
132
     */
133
    public function withHeader($name, $value)
134
    {
135
        return new self($this->psrResponse->withHeader($name, $value));
136
    }
137
138
    /**
139
     * @inheritDoc
140
     */
141
    public function withProtocolVersion($version)
142
    {
143
        return new self($this->psrResponse->withProtocolVersion($version));
144
    }
145
146
    /**
147
     * @inheritDoc
148
     */
149
    public function withStatus($code, $reasonPhrase = '')
150
    {
151
        return new self($this->psrResponse->withStatus($code));
152
    }
153
154
    /**
155
     * @inheritDoc
156
     */
157
    public function withoutHeader($name)
158
    {
159
        return new self($this->psrResponse->withoutHeader($name));
160
    }
161
162
}