Completed
Pull Request — master (#135)
by
unknown
04:36
created

Stack::getDuration()   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
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 Profile[]
21
     */
22
    private $profiles = [];
23
24
    /**
25
     * @var string
26
     */
27
    private $request;
28
29
    /**
30
     * @var string
31
     */
32
    private $response;
33
34
    /**
35
     * @var bool
36
     */
37
    private $failed = false;
38
39
    /**
40
     * @var string
41
     */
42
    private $requestTarget;
43
44
    /**
45
     * @var string
46
     */
47
    private $requestMethod;
48
49
    /**
50
     * @var string
51
     */
52
    private $requestHost;
53
54
    /**
55
     * @var string
56
     */
57
    private $requestScheme;
58
59
    /**
60
     * @var string
61
     */
62
    private $clientRequest;
63
64
    /**
65
     * @var string
66
     */
67
    private $clientResponse;
68
69
    /**
70
     * @var string
71
     */
72
    private $clientException;
73
74
    /**
75
     * @var int
76
     */
77
    private $responseCode;
78
79
    /**
80
     * @var int
81
     */
82
    private $duration = 0;
83
84
    /**
85
     * @param string $client
86
     * @param string $request
87
     */
88 10
    public function __construct($client, $request)
89
    {
90 10
        $this->client = $client;
91 10
        $this->request = $request;
92 10
    }
93
94
    /**
95
     * @return string
96
     */
97 1
    public function getClient()
98
    {
99 1
        return $this->client;
100
    }
101
102
    /**
103
     * @param Profile $profile
104
     */
105 4
    public function addProfile(Profile $profile)
106
    {
107 4
        $this->profiles[] = $profile;
108 4
    }
109
110
    /**
111
     * @return Profile[]
112
     */
113 2
    public function getProfiles()
114
    {
115 2
        return $this->profiles;
116
    }
117
118
    /**
119
     * @return string
120
     */
121 1
    public function getRequest()
122
    {
123 1
        return $this->request;
124
    }
125
126
    /**
127
     * @return string
128
     */
129 1
    public function getResponse()
130
    {
131 1
        return $this->response;
132
    }
133
134
    /**
135
     * @param string $response
136
     */
137 2
    public function setResponse($response)
138
    {
139 2
        $this->response = $response;
140 2
    }
141
142
    /**
143
     * @return bool
144
     */
145
    public function isFailed()
146
    {
147
        return $this->failed;
148
    }
149
150
    /**
151
     * @param bool $failed
152
     */
153 1
    public function setFailed($failed)
154
    {
155 1
        $this->failed = $failed;
156 1
    }
157
158
    /**
159
     * @return string
160
     */
161 2
    public function getRequestTarget()
162
    {
163 2
        return $this->requestTarget;
164
    }
165
166
    /**
167
     * @param string $requestTarget
168
     */
169 3
    public function setRequestTarget($requestTarget)
170
    {
171 3
        $this->requestTarget = $requestTarget;
172 3
    }
173
174
    /**
175
     * @return string
176
     */
177 2
    public function getRequestMethod()
178
    {
179 2
        return $this->requestMethod;
180
    }
181
182
    /**
183
     * @param string $requestMethod
184
     */
185 3
    public function setRequestMethod($requestMethod)
186
    {
187 3
        $this->requestMethod = $requestMethod;
188 3
    }
189
190
    /**
191
     * @return string
192
     */
193
    public function getClientRequest()
194
    {
195
        return $this->clientRequest;
196
    }
197
198
    /**
199
     * @param string $clientRequest
200
     */
201 3
    public function setClientRequest($clientRequest)
202
    {
203 3
        $this->clientRequest = $clientRequest;
204 3
    }
205
206
    /**
207
     * @return mixed
208
     */
209
    public function getClientResponse()
210
    {
211
        return $this->clientResponse;
212
    }
213
214
    /**
215
     * @param mixed $clientResponse
216
     */
217 2
    public function setClientResponse($clientResponse)
218
    {
219 2
        $this->clientResponse = $clientResponse;
220 2
    }
221
222
    /**
223
     * @return string
224
     */
225
    public function getClientException()
226
    {
227
        return $this->clientException;
228
    }
229
230
    /**
231
     * @param string $clientException
232
     */
233
    public function setClientException($clientException)
234
    {
235
        $this->clientException = $clientException;
236
    }
237
238
    /**
239
     * @return int
240
     */
241
    public function getResponseCode()
242
    {
243
        return $this->responseCode;
244
    }
245
246
    /**
247
     * @param int $responseCode
248
     */
249 2
    public function setResponseCode($responseCode)
250
    {
251 2
        $this->responseCode = $responseCode;
252 2
    }
253
254
    /**
255
     * @return string
256
     */
257 2
    public function getRequestHost()
258
    {
259 2
        return $this->requestHost;
260
    }
261
262
    /**
263
     * @param string $requestHost
264
     */
265 3
    public function setRequestHost($requestHost)
266
    {
267 3
        $this->requestHost = $requestHost;
268 3
    }
269
270
    /**
271
     * @return string
272
     */
273 2
    public function getRequestScheme()
274
    {
275 2
        return $this->requestScheme;
276
    }
277
278
    /**
279
     * @param string $requestScheme
280
     */
281 3
    public function setRequestScheme($requestScheme)
282
    {
283 3
        $this->requestScheme = $requestScheme;
284 3
    }
285
286
    /**
287
     * @return int
288
     */
289
    public function getDuration()
290
    {
291
        return $this->duration;
292
    }
293
294
    /**
295
     * @param int $duration
296
     */
297 2
    public function setDuration($duration)
298
    {
299 2
        $this->duration = $duration;
300 2
    }
301
}
302