ServerRequestWithCachedBody   A
last analyzed

Complexity

Total Complexity 32

Size/Duplication

Total Lines 165
Duplicated Lines 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
eloc 36
dl 0
loc 165
rs 9.84
c 1
b 1
f 0
wmc 32

31 Methods

Rating   Name   Duplication   Size   Complexity  
A withCookieParams() 0 3 1
A withUploadedFiles() 0 3 1
A getBody() 0 7 2
A getServerParams() 0 3 1
A withProtocolVersion() 0 3 1
A getHeaders() 0 3 1
A getHeader() 0 3 1
A withAttribute() 0 3 1
A withoutHeader() 0 3 1
A withAddedHeader() 0 3 1
A getUri() 0 3 1
A withBody() 0 3 1
A __construct() 0 3 1
A withRequestTarget() 0 3 1
A getProtocolVersion() 0 3 1
A getCookieParams() 0 3 1
A getUploadedFiles() 0 3 1
A getRequestTarget() 0 3 1
A getMethod() 0 3 1
A getAttribute() 0 3 1
A hasHeader() 0 3 1
A getParsedBody() 0 3 1
A withHeader() 0 3 1
A withoutAttribute() 0 3 1
A withUri() 0 3 1
A getHeaderLine() 0 3 1
A withQueryParams() 0 3 1
A withMethod() 0 3 1
A getAttributes() 0 3 1
A getQueryParams() 0 3 1
A withParsedBody() 0 3 1
1
<?php
2
/**
3
 * This file is part of Phiremock.
4
 *
5
 * Phiremock is free software: you can redistribute it and/or modify
6
 * it under the terms of the GNU Lesser General Public License as published by
7
 * the Free Software Foundation, either version 3 of the License, or
8
 * (at your option) any later version.
9
 *
10
 * Phiremock is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with Phiremock.  If not, see <http://www.gnu.org/licenses/>.
17
 */
18
19
namespace Mcustiel\Phiremock\Server\Http\Implementation;
20
21
use Mcustiel\Phiremock\Common\StringStream;
22
use Psr\Http\Message\ServerRequestInterface;
23
use Psr\Http\Message\StreamInterface;
24
use Psr\Http\Message\UriInterface;
25
26
class ServerRequestWithCachedBody implements ServerRequestInterface
27
{
28
    /** @var ServerRequestInterface */
29
    private $parent;
30
31
    /** @var StreamInterface */
32
    private $body;
33
34
    public function __construct(ServerRequestInterface $serverRequestInterface)
35
    {
36
        $this->parent = $serverRequestInterface;
37
    }
38
39
    public function getBody()
40
    {
41
        if ($this->body === null) {
42
            $this->body = new StringStream($this->parent->getBody()->__toString());
43
        }
44
45
        return $this->body;
46
    }
47
48
    public function getCookieParams()
49
    {
50
        return $this->parent->getCookieParams();
51
    }
52
53
    public function withAttribute($name, $value)
54
    {
55
        return $this->parent->withAttribute($name, $value);
56
    }
57
58
    public function withUri(UriInterface $uri, $preserveHost = false)
59
    {
60
        return $this->parent->withUri($uri, $preserveHost);
61
    }
62
63
    public function getMethod()
64
    {
65
        return $this->parent->getMethod();
66
    }
67
68
    public function withoutHeader($name)
69
    {
70
        return $this->parent->withoutHeader($name);
71
    }
72
73
    public function getHeaderLine($name)
74
    {
75
        return $this->parent->getHeaderLine($name);
76
    }
77
78
    public function getHeader($name)
79
    {
80
        return $this->parent->getHeader($name);
81
    }
82
83
    public function withCookieParams(array $cookies)
84
    {
85
        return $this->parent->withCookieParams($cookies);
86
    }
87
88
    public function getAttribute($name, $default = null)
89
    {
90
        return $this->parent->getAttribute($name, $default);
91
    }
92
93
    public function withUploadedFiles(array $uploadedFiles)
94
    {
95
        return $this->parent->withUploadedFiles($uploadedFiles);
96
    }
97
98
    public function withAddedHeader($name, $value)
99
    {
100
        return $this->parent->withAddedHeader($name, $value);
101
    }
102
103
    public function withQueryParams(array $query)
104
    {
105
        return $this->parent->withQueryParams($query);
106
    }
107
108
    public function withoutAttribute($name)
109
    {
110
        return $this->parent->withoutAttribute($name);
111
    }
112
113
    public function hasHeader($name)
114
    {
115
        return $this->parent->hasHeader($name);
116
    }
117
118
    public function getAttributes()
119
    {
120
        return $this->parent->getAttributes();
121
    }
122
123
    public function getHeaders()
124
    {
125
        return $this->parent->getHeaders();
126
    }
127
128
    public function getRequestTarget()
129
    {
130
        return $this->parent->getRequestTarget();
131
    }
132
133
    public function withRequestTarget($requestTarget)
134
    {
135
        return $this->parent->withRequestTarget($requestTarget);
136
    }
137
138
    public function withProtocolVersion($version)
139
    {
140
        return $this->parent->withProtocolVersion($version);
141
    }
142
143
    public function withHeader($name, $value)
144
    {
145
        return $this->parent->withHeader($name, $value);
146
    }
147
148
    public function withBody(StreamInterface $body)
149
    {
150
        return $this->parent->withBody($body);
151
    }
152
153
    public function getProtocolVersion()
154
    {
155
        return $this->parent->getProtocolVersion();
156
    }
157
158
    public function getParsedBody()
159
    {
160
        return $this->parent->getParsedBody();
161
    }
162
163
    public function withParsedBody($data)
164
    {
165
        return $this->parent->withParsedBody($data);
166
    }
167
168
    public function getUploadedFiles()
169
    {
170
        return $this->parent->getUploadedFiles();
171
    }
172
173
    public function withMethod($method)
174
    {
175
        return $this->parent->withMethod($method);
176
    }
177
178
    public function getServerParams()
179
    {
180
        return $this->parent->getServerParams();
181
    }
182
183
    public function getQueryParams()
184
    {
185
        return $this->parent->getQueryParams();
186
    }
187
188
    public function getUri()
189
    {
190
        return $this->parent->getUri();
191
    }
192
}
193