Completed
Push — master ( 57db8a...f718e5 )
by Tobias
06:48
created

Stack   A

Complexity

Total Complexity 32

Size/Duplication

Total Lines 340
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 0

Test Coverage

Coverage 95%

Importance

Changes 0
Metric Value
wmc 32
lcom 2
cbo 0
dl 0
loc 340
ccs 76
cts 80
cp 0.95
rs 9.84
c 0
b 0
f 0

32 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getClient() 0 4 1
A getParent() 0 4 1
A setParent() 0 4 1
A addProfile() 0 4 1
A getProfiles() 0 4 1
A getRequest() 0 4 1
A getResponse() 0 4 1
A setResponse() 0 4 1
A isFailed() 0 4 1
A setFailed() 0 4 1
A getRequestTarget() 0 4 1
A setRequestTarget() 0 4 1
A getRequestMethod() 0 4 1
A setRequestMethod() 0 4 1
A getClientRequest() 0 4 1
A setClientRequest() 0 4 1
A getClientResponse() 0 4 1
A setClientResponse() 0 4 1
A getClientException() 0 4 1
A setClientException() 0 4 1
A getResponseCode() 0 4 1
A setResponseCode() 0 4 1
A getRequestHost() 0 4 1
A setRequestHost() 0 4 1
A getRequestScheme() 0 4 1
A setRequestScheme() 0 4 1
A getDuration() 0 4 1
A setDuration() 0 4 1
A getCurlCommand() 0 4 1
A setCurlCommand() 0 4 1
A getClientSlug() 0 4 1
1
<?php
2
3
namespace Http\HttplugBundle\Collector;
4
5
/**
6
 * A Stack hold a collection of Profile to track the whole request execution.
7
 *
8
 * @author Fabien Bourigault <[email protected]>
9
 *
10
 * @internal
11
 */
12
final class Stack
13
{
14
    /**
15
     * @var string
16
     */
17
    private $client;
18
19
    /**
20
     * @var Stack
21
     */
22
    private $parent;
23
24
    /**
25
     * @var Profile[]
26
     */
27
    private $profiles = [];
28
29
    /**
30
     * @var string
31
     */
32
    private $request;
33
34
    /**
35
     * @var string
36
     */
37
    private $response;
38
39
    /**
40
     * @var bool
41
     */
42
    private $failed = false;
43
44
    /**
45
     * @var string
46
     */
47
    private $requestTarget;
48
49
    /**
50
     * @var string
51
     */
52
    private $requestMethod;
53
54
    /**
55
     * @var string
56
     */
57
    private $requestHost;
58
59
    /**
60
     * @var string
61
     */
62
    private $requestScheme;
63
64
    /**
65
     * @var string
66
     */
67
    private $clientRequest;
68
69
    /**
70
     * @var string
71
     */
72
    private $clientResponse;
73
74
    /**
75
     * @var string
76
     */
77
    private $clientException;
78
79
    /**
80
     * @var int
81
     */
82
    private $responseCode;
83
84
    /**
85
     * @var int
86
     */
87
    private $duration = 0;
88
89
    /**
90
     * @var string
91
     */
92
    private $curlCommand;
93
94
    /**
95
     * @param string $client
96
     * @param string $request
97
     */
98 23
    public function __construct($client, $request)
99
    {
100 23
        $this->client = $client;
101 23
        $this->request = $request;
102 23
    }
103
104
    /**
105
     * @return string
106
     */
107 3
    public function getClient()
108
    {
109 3
        return $this->client;
110
    }
111
112
    /**
113
     * @return Stack
114
     */
115 8
    public function getParent()
116
    {
117 8
        return $this->parent;
118
    }
119
120
    /**
121
     * @param Stack $parent
122
     */
123 2
    public function setParent(self $parent)
124
    {
125 2
        $this->parent = $parent;
0 ignored issues
show
Documentation Bug introduced by
It seems like $parent of type object<self> is incompatible with the declared type object<Http\HttplugBundle\Collector\Stack> of property $parent.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
126 2
    }
127
128
    /**
129
     * @param Profile $profile
130
     */
131 8
    public function addProfile(Profile $profile)
132
    {
133 8
        $this->profiles[] = $profile;
134 8
    }
135
136
    /**
137
     * @return Profile[]
138
     */
139 4
    public function getProfiles()
140
    {
141 4
        return $this->profiles;
142
    }
143
144
    /**
145
     * @return string
146
     */
147 1
    public function getRequest()
148
    {
149 1
        return $this->request;
150
    }
151
152
    /**
153
     * @return string
154
     */
155 1
    public function getResponse()
156
    {
157 1
        return $this->response;
158
    }
159
160
    /**
161
     * @param string $response
162
     */
163 5
    public function setResponse($response)
164
    {
165 5
        $this->response = $response;
166 5
    }
167
168
    /**
169
     * @return bool
170
     */
171
    public function isFailed()
172
    {
173
        return $this->failed;
174
    }
175
176
    /**
177
     * @param bool $failed
178
     */
179 1
    public function setFailed($failed)
180
    {
181 1
        $this->failed = $failed;
182 1
    }
183
184
    /**
185
     * @return string
186
     */
187 10
    public function getRequestTarget()
188
    {
189 10
        return $this->requestTarget;
190
    }
191
192
    /**
193
     * @param string $requestTarget
194
     */
195 12
    public function setRequestTarget($requestTarget)
196
    {
197 12
        $this->requestTarget = $requestTarget;
198 12
    }
199
200
    /**
201
     * @return string
202
     */
203 10
    public function getRequestMethod()
204
    {
205 10
        return $this->requestMethod;
206
    }
207
208
    /**
209
     * @param string $requestMethod
210
     */
211 12
    public function setRequestMethod($requestMethod)
212
    {
213 12
        $this->requestMethod = $requestMethod;
214 12
    }
215
216
    /**
217
     * @return string
218
     */
219 8
    public function getClientRequest()
220
    {
221 8
        return $this->clientRequest;
222
    }
223
224
    /**
225
     * @param string $clientRequest
226
     */
227 12
    public function setClientRequest($clientRequest)
228
    {
229 12
        $this->clientRequest = $clientRequest;
230 12
    }
231
232
    /**
233
     * @return mixed
234
     */
235 1
    public function getClientResponse()
236
    {
237 1
        return $this->clientResponse;
238
    }
239
240
    /**
241
     * @param mixed $clientResponse
242
     */
243 5
    public function setClientResponse($clientResponse)
244
    {
245 5
        $this->clientResponse = $clientResponse;
246 5
    }
247
248
    /**
249
     * @return string
250
     */
251 1
    public function getClientException()
252
    {
253 1
        return $this->clientException;
254
    }
255
256
    /**
257
     * @param string $clientException
258
     */
259 1
    public function setClientException($clientException)
260
    {
261 1
        $this->clientException = $clientException;
262 1
    }
263
264
    /**
265
     * @return int
266
     */
267 1
    public function getResponseCode()
268
    {
269 1
        return $this->responseCode;
270
    }
271
272
    /**
273
     * @param int $responseCode
274
     */
275 5
    public function setResponseCode($responseCode)
276
    {
277 5
        $this->responseCode = $responseCode;
278 5
    }
279
280
    /**
281
     * @return string
282
     */
283 10
    public function getRequestHost()
284
    {
285 10
        return $this->requestHost;
286
    }
287
288
    /**
289
     * @param string $requestHost
290
     */
291 12
    public function setRequestHost($requestHost)
292
    {
293 12
        $this->requestHost = $requestHost;
294 12
    }
295
296
    /**
297
     * @return string
298
     */
299 10
    public function getRequestScheme()
300
    {
301 10
        return $this->requestScheme;
302
    }
303
304
    /**
305
     * @param string $requestScheme
306
     */
307 12
    public function setRequestScheme($requestScheme)
308
    {
309 12
        $this->requestScheme = $requestScheme;
310 12
    }
311
312
    /**
313
     * @return int
314
     */
315 2
    public function getDuration()
316
    {
317 2
        return $this->duration;
318
    }
319
320
    /**
321
     * @param int $duration
322
     */
323 6
    public function setDuration($duration)
324
    {
325 6
        $this->duration = $duration;
326 6
    }
327
328
    /**
329
     * @return string
330
     */
331 8
    public function getCurlCommand()
332
    {
333 8
        return $this->curlCommand;
334
    }
335
336
    /**
337
     * @param string $curlCommand
338
     */
339 12
    public function setCurlCommand($curlCommand)
340
    {
341 12
        $this->curlCommand = $curlCommand;
342 12
    }
343
344
    /**
345
     * @return string
346
     */
347
    public function getClientSlug()
348
    {
349
        return preg_replace('/[^a-zA-Z0-9_-]/u', '_', $this->client);
350
    }
351
}
352