GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

LogRequest::setHost()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace EightPoints\Bundle\GuzzleBundle\Log;
4
5
use Psr\Http\Message\RequestInterface;
6
7
class LogRequest
8
{
9
    /** @var string */
10
    protected $host;
11
12
    /** @var integer|null */
13
    protected $port;
14
15
    /** @var string */
16
    protected $url;
17
18
    /** @var string */
19
    protected $path;
20
21
    /** @var string */
22
    protected $scheme;
23
24
    /** @var string[][] */
25
    protected $headers = [];
26
27
    /** @var string */
28
    protected $protocolVersion;
29
30
    /** @var string */
31
    protected $method;
32
33
    /** @var string|null */
34
    protected $body;
35
36
    /**
37
     * @param \Psr\Http\Message\RequestInterface $request
38
     */
39
    public function __construct(RequestInterface $request)
40
    {
41
        $this->save($request);
42
    }
43
44
    /**
45
     * Save data
46
     *
47
     * @param \Psr\Http\Message\RequestInterface $request
48
     *
49
     * @return void
50
     */
51
    protected function save(RequestInterface $request) : void
52
    {
53
        $uri = $request->getUri();
54
55
        $this->setHost($uri->getHost());
56
        $this->setPort($uri->getPort());
57
        $this->setUrl((string) $uri);
58
        $this->setPath($uri->getPath());
59
        $this->setScheme($uri->getScheme());
60
        $this->setHeaders($request->getHeaders());
61
        $this->setProtocolVersion($request->getProtocolVersion());
62
        $this->setMethod($request->getMethod());
63
64
        // rewind to previous position after logging request
65
        $readPosition = null;
66
        if ($request->getBody() && $request->getBody()->isSeekable()) {
67
            $readPosition = $request->getBody()->tell();
68
        }
69
70
        $this->setBody($request->getBody() ? $request->getBody()->__toString() : null);
71
72
        if ($readPosition !== null) {
73
            $request->getBody()->seek($readPosition);
74
        }
75
    }
76
77
    /**
78
     * Return host
79
     *
80
     * @return string
81
     */
82
    public function getHost() : string
83
    {
84
        return $this->host;
85
    }
86
87
    /**
88
     * Set request host
89
     *
90
     * @param string $value
91
     *
92
     * @return void
93
     */
94
    public function setHost(string $value) : void
95
    {
96
        $this->host = $value;
97
    }
98
99
    /**
100
     * Return port
101
     *
102
     * @return integer|null
103
     */
104
    public function getPort() : ?int
105
    {
106
        return $this->port;
107
    }
108
109
    /**
110
     * Set port
111
     *
112
     * @param integer|null $value
113
     *
114
     * @return void
115
     */
116
    public function setPort(?int $value): void
117
    {
118
        $this->port = $value;
119
    }
120
121
    /**
122
     * Return url
123
     *
124
     * @return string
125
     */
126
    public function getUrl() : string
127
    {
128
        return $this->url;
129
    }
130
131
    /**
132
     * Set url
133
     *
134
     * @param string $value
135
     *
136
     * @return void
137
     */
138
    public function setUrl(string $value) : void
139
    {
140
        $this->url = $value;
141
    }
142
143
    /**
144
     * Return path
145
     *
146
     * @return string
147
     */
148
    public function getPath() : string
149
    {
150
        return $this->path;
151
    }
152
153
    /**
154
     * Set path
155
     *
156
     * @param string $value
157
     *
158
     * @return void
159
     */
160
    public function setPath(string $value) : void
161
    {
162
        $this->path = $value;
163
    }
164
165
    /**
166
     * Return scheme
167
     *
168
     * @return string
169
     */
170
    public function getScheme() : string
171
    {
172
        return $this->scheme;
173
    }
174
175
    /**
176
     * Set scheme
177
     *
178
     * @param string $value
179
     *
180
     * @return void
181
     */
182
    public function setScheme(string $value) : void
183
    {
184
        $this->scheme = $value;
185
    }
186
187
    /**
188
     * Return headers
189
     *
190
     * @return array
191
     */
192
    public function getHeaders() : array
193
    {
194
        return $this->headers;
195
    }
196
197
    /**
198
     * Set headers
199
     *
200
     * @param array $value
201
     *
202
     * @return void
203
     */
204
    public function setHeaders(array $value) : void
205
    {
206
        $this->headers = $value;
207
    }
208
209
    /**
210
     * Return protocol version
211
     *
212
     * @return string
213
     */
214
    public function getProtocolVersion() : string
215
    {
216
        return $this->protocolVersion;
217
    }
218
219
    /**
220
     * Set protocol version
221
     *
222
     * @param string $value
223
     *
224
     * @return void
225
     */
226
    public function setProtocolVersion(string $value) : void
227
    {
228
        $this->protocolVersion = $value;
229
    }
230
231
    /**
232
     * Return method
233
     *
234
     * @return string
235
     */
236
    public function getMethod() : string
237
    {
238
        return $this->method;
239
    }
240
241
    /**
242
     * Set method
243
     *
244
     * @param string $value
245
     *
246
     * @return void
247
     */
248
    public function setMethod(string $value) : void
249
    {
250
        $this->method = $value;
251
    }
252
253
    /**
254
     * Return body
255
     *
256
     * @return string|null
257
     */
258
    public function getBody() : ?string
259
    {
260
        return $this->body;
261
    }
262
263
    /**
264
     * Set body
265
     *
266
     * @param string|null $value
267
     *
268
     * @return void
269
     */
270
    public function setBody(?string $value) : void
271
    {
272
        $this->body = $value;
273
    }
274
}
275