Completed
Pull Request — master (#135)
by
unknown
08:15
created

Stack::setResponse()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 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 Profile[]
21
     */
22
    private $profiles = [];
23
24
    /**
25
     * @var string
26
     */
27
    private $request;
28
29
    /**
30
     * @var string
31
     */
32
    private $method;
33
34
    /**
35
     * @var string
36
     */
37
    private $target;
38
39
    /**
40
     * @var string
41
     */
42
    private $response;
43
44
    /**
45
     * @var bool
46
     */
47
    private $failed = false;
48
49
    /**
50
     * @var int
51
     */
52
    private $duration = 0;
53
54
    /**
55
     * @var int|null
56
     */
57
    private $responseCode;
58
59
    /**
60
     * @param string $client
61
     * @param string $method
62
     * @param string $target
63
     * @param string $request
64
     */
65 7
    public function __construct($client, $method, $target, $request)
66
    {
67 7
        $this->client = $client;
68 7
        $this->method = $method;
69 7
        $this->target = $target;
70 7
        $this->request = $request;
71 7
    }
72
73
    /**
74
     * @return string
75
     */
76 1
    public function getClient()
77
    {
78 1
        return $this->client;
79
    }
80
81
    /**
82
     * @param Profile $profile
83
     */
84 4
    public function addProfile(Profile $profile)
85
    {
86 4
        $this->profiles[] = $profile;
87 4
    }
88
89
    /**
90
     * @return Profile[]
91
     */
92 2
    public function getProfiles()
93
    {
94 2
        return $this->profiles;
95
    }
96
97
    /**
98
     * @return string
99
     */
100
    public function getMethod()
101
    {
102
        return $this->method;
103
    }
104
105
    /**
106
     * @return string
107
     */
108
    public function getTarget()
109
    {
110
        return $this->target;
111
    }
112
113
    /**
114
     * @return string
115
     */
116 1
    public function getRequest()
117
    {
118 1
        return $this->request;
119
    }
120
121
    /**
122
     * @return string
123
     */
124 1
    public function getResponse()
125
    {
126 1
        return $this->response;
127
    }
128
129
    /**
130
     * @param string $response
131
     */
132 2
    public function setResponse($response)
133
    {
134 2
        $this->response = $response;
135 2
    }
136
137
    /**
138
     * @return bool
139
     */
140
    public function isFailed()
141
    {
142
        return $this->failed;
143
    }
144
145
    /**
146
     * @param bool $failed
147
     */
148 1
    public function setFailed($failed)
149
    {
150 1
        $this->failed = $failed;
151 1
    }
152
153
    /**
154
     * @return int
155
     */
156
    public function getDuration()
157
    {
158
        return $this->duration;
159
    }
160
161
    /**
162
     * @param int $duration
163
     */
164
    public function setDuration($duration)
165
    {
166
        $this->duration = $duration;
167
    }
168
169
    /**
170
     * @return int|null
171
     */
172
    public function getResponseCode()
173
    {
174
        return $this->responseCode;
175
    }
176
177
    /**
178
     * @param int|null $responseCode
179
     */
180 1
    public function setResponseCode($responseCode)
181
    {
182 1
        $this->responseCode = $responseCode;
183 1
    }
184
}
185