@@ -97,11 +97,14 @@ public function send()
9797 }
9898
9999 /**
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+ *
102105 * @throws \Exception
103106 */
104- public function sendHtml (string $ body , int $ status = 200 )
107+ public function sendHtml (string $ body , int $ status = ResponseStatus::OkCode )
105108 {
106109 $ config = WaterPipeConfig::get ();
107110
@@ -113,8 +116,11 @@ public function sendHtml(string $body, int $status = 200)
113116 }
114117
115118 /**
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+ *
118124 * @throws \Exception
119125 */
120126 public function sendJsonString (string $ body , int $ status = 200 )
@@ -129,8 +135,11 @@ public function sendJsonString(string $body, int $status = 200)
129135 }
130136
131137 /**
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+ *
134143 * @throws \Exception
135144 */
136145 public function sendJson (array $ json , int $ status = 200 )
@@ -139,8 +148,11 @@ public function sendJson(array $json, int $status = 200)
139148 }
140149
141150 /**
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+ *
144156 * @throws \Exception
145157 */
146158 public function sendText (string $ body , int $ status = 200 )
@@ -155,10 +167,14 @@ public function sendText(string $body, int $status = 200)
155167 }
156168
157169 /**
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+ *
161176 * @throws \Exception
177+ * @throws FileNotFoundException When the file was not found at the given path.
162178 */
163179 public function sendFile (string $ path , int $ status = 200 , string $ mime = null )
164180 {
@@ -181,26 +197,44 @@ public function sendFile(string $path, int $status = 200, string $mime = null)
181197 }
182198
183199 /**
184- * @param string $body
200+ * Set the response body.
201+ *
202+ * @param string $body The body.
203+ *
204+ * @return self For chain calls.
185205 */
186- public function setBody (string $ body ): void
206+ public function setBody (string $ body ): self
187207 {
188208 $ this ->_body = $ body ;
209+
210+ return $ this ;
189211 }
190212
191213 /**
192- * @param ResponseStatus $status
214+ * Set the response status.
215+ *
216+ * @param ResponseStatus $status The status code.
217+ *
218+ * @return self For chain calls.
193219 */
194- public function setStatus (ResponseStatus $ status ): void
220+ public function setStatus (ResponseStatus $ status ): self
195221 {
196222 $ this ->_status = $ status ;
223+
224+ return $ this ;
197225 }
198226
199227 /**
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.
201233 */
202- public function setHeader (ResponseHeader $ header ): void
234+ public function setHeader (ResponseHeader $ header ): self
203235 {
204236 $ this ->_header = $ header ;
237+
238+ return $ this ;
205239 }
206240}
0 commit comments