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

Request::route()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php declare(strict_types = 1);
2
3
namespace Venta\Http;
4
5
use Psr\Http\Message\ServerRequestInterface;
6
use Psr\Http\Message\StreamInterface;
7
use Psr\Http\Message\UriInterface;
8
use Venta\Contracts\Http\Request as RequestContract;
9
use Venta\Contracts\Routing\Route;
10
11
/**
12
 * Class Request
13
 *
14
 * @package Venta\Http
15
 */
16
class Request implements RequestContract
17
{
18
    /**
19
     * @var ServerRequestInterface
20
     */
21
    private $psrRequest;
22
23
    /**
24
     * Request constructor.
25
     *
26
     * @param ServerRequestInterface $psrRequest
27
     */
28 4
    public function __construct(ServerRequestInterface $psrRequest)
29
    {
30 4
        $this->psrRequest = $psrRequest;
31 4
    }
32
33
    /**
34
     * @inheritDoc
35
     */
36
    public function getAttribute($name, $default = null)
37
    {
38
        return $this->psrRequest->getAttribute($name, $default);
39
    }
40
41
    /**
42
     * @inheritDoc
43
     */
44
    public function getAttributes()
45
    {
46
        return $this->psrRequest->getAttributes();
47
    }
48
49
    /**
50
     * @inheritDoc
51
     */
52
    public function getBody()
53
    {
54
        return $this->psrRequest->getBody();
55
    }
56
57
    /**
58
     * @inheritDoc
59
     */
60
    public function getCookieParams()
61
    {
62
        return $this->psrRequest->getCookieParams();
63
    }
64
65
    /**
66
     * @inheritDoc
67
     */
68
    public function getHeader($name)
69
    {
70
        return $this->psrRequest->getHeader($name);
71
    }
72
73
    /**
74
     * @inheritDoc
75
     */
76
    public function getHeaderLine($name)
77
    {
78
        return $this->psrRequest->getHeaderLine($name);
79
    }
80
81
    /**
82
     * @inheritDoc
83
     */
84
    public function getHeaders()
85
    {
86
        return $this->psrRequest->getHeaders();
87
    }
88
89
    /**
90
     * @inheritDoc
91
     */
92 2
    public function getMethod()
93
    {
94 2
        return $this->psrRequest->getMethod();
95
    }
96
97
    /**
98
     * @inheritDoc
99
     */
100
    public function getParsedBody()
101
    {
102
        return $this->psrRequest->getParsedBody();
103
    }
104
105
    /**
106
     * @inheritDoc
107
     */
108
    public function getProtocolVersion()
109
    {
110
        return $this->psrRequest->getProtocolVersion();
111
    }
112
113
    /**
114
     * @inheritDoc
115
     */
116
    public function getQueryParams()
117
    {
118
        return $this->psrRequest->getQueryParams();
119
    }
120
121
    /**
122
     * @inheritDoc
123
     */
124
    public function getRequestTarget()
125
    {
126
        return $this->psrRequest->getRequestTarget();
127
    }
128
129
    /**
130
     * @inheritDoc
131
     */
132
    public function route(): Route
133
    {
134
        return $this->getAttribute('route');
135
    }
136
137
    /**
138
     * @inheritDoc
139
     */
140
    public function getServerParams()
141
    {
142
        return $this->psrRequest->getServerParams();
143
    }
144
145
    /**
146
     * @inheritDoc
147
     */
148
    public function getUploadedFiles()
149
    {
150
        return $this->psrRequest->getUploadedFiles();
151
    }
152
153
    /**
154
     * @inheritDoc
155
     */
156 2
    public function getUri()
157
    {
158 2
        return $this->psrRequest->getUri();
159
    }
160
161
    /**
162
     * @inheritDoc
163
     */
164
    public function hasHeader($name)
165
    {
166
        return $this->psrRequest->hasHeader($name);
167
    }
168
169
    /**
170
     * @inheritDoc
171
     */
172
    public function withAddedHeader($name, $value)
173
    {
174
        return new self($this->psrRequest->withAddedHeader($name, $value));
175
    }
176
177
    /**
178
     * @inheritDoc
179
     */
180
    public function withAttribute($name, $value)
181
    {
182
        return new self($this->psrRequest->withAttribute($name, $value));
183
    }
184
185
    /**
186
     * @inheritDoc
187
     */
188
    public function withBody(StreamInterface $body)
189
    {
190
        return new self($this->psrRequest->withBody($body));
191
    }
192
193
    /**
194
     * @inheritDoc
195
     */
196
    public function withCookieParams(array $cookies)
197
    {
198
        return new self($this->psrRequest->withCookieParams($cookies));
199
    }
200
201
    /**
202
     * @inheritDoc
203
     */
204
    public function withHeader($name, $value)
205
    {
206
        return new self($this->psrRequest->withHeader($name, $value));
207
    }
208
209
    /**
210
     * @inheritDoc
211
     */
212
    public function withMethod($method)
213
    {
214
        return new self($this->psrRequest->withMethod($method));
215
    }
216
217
    /**
218
     * @inheritDoc
219
     */
220
    public function withParsedBody($data)
221
    {
222
        return new self($this->psrRequest->withParsedBody($data));
223
    }
224
225
    /**
226
     * @inheritDoc
227
     */
228
    public function withProtocolVersion($version)
229
    {
230
        return new self($this->psrRequest->withProtocolVersion($version));
231
    }
232
233
    /**
234
     * @inheritDoc
235
     */
236
    public function withQueryParams(array $query)
237
    {
238
        return new self($this->psrRequest->withQueryParams($query));
239
    }
240
241
    /**
242
     * @inheritDoc
243
     */
244
    public function withRequestTarget($requestTarget)
245
    {
246
        return new self($this->psrRequest->withRequestTarget($requestTarget));
247
    }
248
249
    /**
250
     * @inheritDoc
251
     */
252
    public function withRoute(Route $route): RequestContract
253
    {
254
        return $this->withAttribute('route', $route);
255
    }
256
257
    /**
258
     * @inheritDoc
259
     */
260
    public function withUploadedFiles(array $uploadedFiles)
261
    {
262
        return new self($this->psrRequest->withUploadedFiles($uploadedFiles));
263
    }
264
265
    /**
266
     * @inheritDoc
267
     */
268
    public function withUri(UriInterface $uri, $preserveHost = false)
269
    {
270
        return new self($this->psrRequest->withUri($uri, $preserveHost));
271
    }
272
273
    /**
274
     * @inheritDoc
275
     */
276
    public function withoutAttribute($name)
277
    {
278
        return new self($this->psrRequest->withoutAttribute($name));
279
    }
280
281
    /**
282
     * @inheritDoc
283
     */
284
    public function withoutHeader($name)
285
    {
286
        return new self($this->psrRequest->withoutHeader($name));
287
    }
288
289
}