@@ -97,11 +97,14 @@ public function send()
97
97
}
98
98
99
99
/**
100
- * @param string $body
101
- * @param int $status
100
+ * Sends an HTML string.
101
+ *
102
+ * @param string $body The HTML string.
103
+ * @param int $status The status code.
104
+ *
102
105
* @throws \Exception
103
106
*/
104
- public function sendHtml (string $ body , int $ status = 200 )
107
+ public function sendHtml (string $ body , int $ status = ResponseStatus::OkCode )
105
108
{
106
109
$ config = WaterPipeConfig::get ();
107
110
@@ -113,8 +116,11 @@ public function sendHtml(string $body, int $status = 200)
113
116
}
114
117
115
118
/**
116
- * @param string $body
117
- * @param int $status
119
+ * Send a JSON string.
120
+ *
121
+ * @param string $body The JSON string.
122
+ * @param int $status The status code.
123
+ *
118
124
* @throws \Exception
119
125
*/
120
126
public function sendJsonString (string $ body , int $ status = 200 )
@@ -129,8 +135,11 @@ public function sendJsonString(string $body, int $status = 200)
129
135
}
130
136
131
137
/**
132
- * @param array $json
133
- * @param int $status
138
+ * Send an array encoded to JSON.
139
+ *
140
+ * @param array $json The JSON array.
141
+ * @param int $status The status code.
142
+ *
134
143
* @throws \Exception
135
144
*/
136
145
public function sendJson (array $ json , int $ status = 200 )
@@ -139,8 +148,11 @@ public function sendJson(array $json, int $status = 200)
139
148
}
140
149
141
150
/**
142
- * @param string $body
143
- * @param int $status
151
+ * Send a raw string.
152
+ *
153
+ * @param string $body The raw string.
154
+ * @param int $status The status code.
155
+ *
144
156
* @throws \Exception
145
157
*/
146
158
public function sendText (string $ body , int $ status = 200 )
@@ -155,10 +167,14 @@ public function sendText(string $body, int $status = 200)
155
167
}
156
168
157
169
/**
158
- * @param string $path
159
- * @param int $status
160
- * @param string|null $mime
170
+ * Send a file content.
171
+ *
172
+ * @param string $path The path to the file.
173
+ * @param int $status The status code.
174
+ * @param string|null $mime The file's MIME type.
175
+ *
161
176
* @throws \Exception
177
+ * @throws FileNotFoundException When the file was not found at the given path.
162
178
*/
163
179
public function sendFile (string $ path , int $ status = 200 , string $ mime = null )
164
180
{
@@ -181,26 +197,44 @@ public function sendFile(string $path, int $status = 200, string $mime = null)
181
197
}
182
198
183
199
/**
184
- * @param string $body
200
+ * Set the response body.
201
+ *
202
+ * @param string $body The body.
203
+ *
204
+ * @return self For chain calls.
185
205
*/
186
- public function setBody (string $ body ): void
206
+ public function setBody (string $ body ): self
187
207
{
188
208
$ this ->_body = $ body ;
209
+
210
+ return $ this ;
189
211
}
190
212
191
213
/**
192
- * @param ResponseStatus $status
214
+ * Set the response status.
215
+ *
216
+ * @param ResponseStatus $status The status code.
217
+ *
218
+ * @return self For chain calls.
193
219
*/
194
- public function setStatus (ResponseStatus $ status ): void
220
+ public function setStatus (ResponseStatus $ status ): self
195
221
{
196
222
$ this ->_status = $ status ;
223
+
224
+ return $ this ;
197
225
}
198
226
199
227
/**
200
- * @param ResponseHeader $header
228
+ * Set the response header.
229
+ *
230
+ * @param ResponseHeader $header The response header object.
231
+ *
232
+ * @return self For chain calls.
201
233
*/
202
- public function setHeader (ResponseHeader $ header ): void
234
+ public function setHeader (ResponseHeader $ header ): self
203
235
{
204
236
$ this ->_header = $ header ;
237
+
238
+ return $ this ;
205
239
}
206
240
}
0 commit comments