1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Rss/Atom Bundle for Symfony. |
5
|
|
|
* |
6
|
|
|
* |
7
|
|
|
* @license http://opensource.org/licenses/lgpl-3.0.html LGPL |
8
|
|
|
* @copyright (c) 2013, Alexandre Debril |
9
|
|
|
*/ |
10
|
|
|
namespace Debril\RssAtomBundle\Driver; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* Class HttpDriverResponse. |
14
|
|
|
*/ |
15
|
|
|
class HttpDriverResponse |
16
|
|
|
{ |
17
|
|
|
const HTTP_CODE_OK = 200; |
18
|
|
|
const HTTP_CODE_MOVE_PERMANENTLY = 301; |
19
|
|
|
const HTTP_CODE_FOUND = 302; |
20
|
|
|
const HTTP_CODE_NOT_MODIFIED = 304; |
21
|
|
|
const HTTP_CODE_FORBIDDEN = 403; |
22
|
|
|
const HTTP_CODE_NOT_FOUND = 404; |
23
|
|
|
const HTTP_CODE_SERVER_ERROR = 500; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @var string |
27
|
|
|
*/ |
28
|
|
|
protected $body; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @var array |
32
|
|
|
*/ |
33
|
|
|
protected $headers; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @var int |
37
|
|
|
*/ |
38
|
|
|
protected $httpCode; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @var string |
42
|
|
|
*/ |
43
|
|
|
protected $httpVersion; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @var string |
47
|
|
|
*/ |
48
|
|
|
protected $httpMessage; |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @return bool |
52
|
|
|
*/ |
53
|
2 |
|
public function getHttpCodeIsOk() |
54
|
|
|
{ |
55
|
2 |
|
return $this->getHttpCode() === self::HTTP_CODE_OK; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @return bool |
60
|
|
|
*/ |
61
|
|
|
public function getHttpCodeIsRedirection() |
62
|
|
|
{ |
63
|
|
|
return in_array( |
64
|
|
|
$this->getHttpCode(), |
65
|
|
|
array( |
66
|
|
|
self::HTTP_CODE_MOVE_PERMANENTLY, |
67
|
|
|
self::HTTP_CODE_FOUND, |
68
|
|
|
) |
69
|
|
|
); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* @return bool |
74
|
|
|
*/ |
75
|
|
|
public function getHttpCodeIsCached() |
76
|
|
|
{ |
77
|
|
|
return in_array( |
78
|
|
|
$this->getHttpCode(), |
79
|
|
|
array( |
80
|
|
|
self::HTTP_CODE_NOT_MODIFIED, |
81
|
|
|
) |
82
|
|
|
); |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* @return int |
87
|
|
|
*/ |
88
|
2 |
|
public function getHttpCode() |
89
|
|
|
{ |
90
|
2 |
|
return $this->httpCode; |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* @param int $httpCode |
95
|
|
|
* |
96
|
|
|
* @return HttpDriverResponse |
97
|
|
|
*/ |
98
|
3 |
|
public function setHttpCode($httpCode) |
99
|
|
|
{ |
100
|
3 |
|
$this->httpCode = (int) $httpCode; |
101
|
|
|
|
102
|
3 |
|
return $this; |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* @return string |
107
|
|
|
*/ |
108
|
1 |
|
public function getHttpVersion() |
109
|
|
|
{ |
110
|
1 |
|
return $this->httpVersion; |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
/** |
114
|
|
|
* @param string $httpVersion |
115
|
|
|
* |
116
|
|
|
* @return HttpDriverResponse |
117
|
|
|
*/ |
118
|
2 |
|
public function setHttpVersion($httpVersion) |
119
|
|
|
{ |
120
|
2 |
|
$this->httpVersion = $httpVersion; |
121
|
|
|
|
122
|
2 |
|
return $this; |
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
/** |
126
|
|
|
* @return string |
127
|
|
|
*/ |
128
|
1 |
|
public function getHttpMessage() |
129
|
|
|
{ |
130
|
1 |
|
return $this->httpMessage; |
131
|
|
|
} |
132
|
|
|
|
133
|
|
|
/** |
134
|
|
|
* @param string $httpMessage |
135
|
|
|
* |
136
|
|
|
* @return HttpDriverResponse |
137
|
|
|
*/ |
138
|
2 |
|
public function setHttpMessage($httpMessage) |
139
|
|
|
{ |
140
|
2 |
|
$this->httpMessage = $httpMessage; |
141
|
|
|
|
142
|
2 |
|
return $this; |
143
|
|
|
} |
144
|
|
|
|
145
|
|
|
/** |
146
|
|
|
* @return string |
147
|
|
|
*/ |
148
|
1 |
|
public function getHeaders() |
149
|
|
|
{ |
150
|
1 |
|
return $this->headers; |
151
|
|
|
} |
152
|
|
|
|
153
|
|
|
/** |
154
|
|
|
* @param string $headers |
155
|
|
|
* |
156
|
|
|
* @return HttpDriverResponse |
157
|
|
|
*/ |
158
|
2 |
|
public function setHeaders($headers) |
159
|
|
|
{ |
160
|
2 |
|
$this->headers = $headers; |
|
|
|
|
161
|
|
|
|
162
|
2 |
|
return $this; |
163
|
|
|
} |
164
|
|
|
|
165
|
|
|
/** |
166
|
|
|
* @return string |
167
|
|
|
*/ |
168
|
2 |
|
public function getBody() |
169
|
|
|
{ |
170
|
2 |
|
return $this->body; |
171
|
|
|
} |
172
|
|
|
|
173
|
|
|
/** |
174
|
|
|
* @param string $body |
175
|
|
|
* |
176
|
|
|
* @return HttpDriverResponse |
177
|
|
|
*/ |
178
|
3 |
|
public function setBody($body) |
179
|
|
|
{ |
180
|
3 |
|
$this->body = $body; |
181
|
|
|
|
182
|
3 |
|
return $this; |
183
|
|
|
} |
184
|
|
|
} |
185
|
|
|
|
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..