diff options
Diffstat (limited to 'system/classes/response.php')
-rw-r--r-- | system/classes/response.php | 93 |
1 files changed, 49 insertions, 44 deletions
diff --git a/system/classes/response.php b/system/classes/response.php index b1b38cc..a4b737e 100644 --- a/system/classes/response.php +++ b/system/classes/response.php @@ -4,67 +4,72 @@ * Handles the response that is sent back to the client.
* @package Core
*/
-class Response {
+class Response
+{
- /**
- * Headers for the response
- * @var array
- * @access public
- */
+ /**
+ * Headers for the response
+ * @var array
+ * @access public
+ */
public $headers = array(
'Content-Type: text/html; charset=utf-8'
);
- /**
- * Response body
- * @var string
- * @access public
- */
+ /**
+ * Response body
+ * @var string
+ * @access public
+ */
public $body;
- /**
- * Add header to the response
- *
- * @param string $header Header content
- * @return void
- * @access public
- */
- public function add_header($header){
- $this->headers[]=$header;
+ /**
+ * Add header to the response
+ *
+ * @param string $header Header content
+ * @return void
+ * @access public
+ */
+ public function add_header($header)
+ {
+ $this->headers[] = $header;
}
- /**
- * Add redirection header
- *
- * @param string $url URL to redirect the client to
- * @return void
- * @access public
- */
- public function redirect($url){
+ /**
+ * Add redirection header
+ *
+ * @param string $url URL to redirect the client to
+ * @return void
+ * @access public
+ */
+ public function redirect($url)
+ {
$this->add_header("Location: $url");
}
- /**
- * Sends headers to the client
- *
- * @return Response Same Response object, for method chaining
- * @access public
- */
- public function send_headers(){
- foreach($this->headers as $header)
+ /**
+ * Sends headers to the client
+ *
+ * @return Response Same Response object, for method chaining
+ * @access public
+ */
+ public function send_headers()
+ {
+ foreach ($this->headers as $header)
header($header);
return $this;
}
- /**
- * Send response body to the client
- *
- * @return object Same Response object, for method chaining
- * @access public
- */
- public function send_body(){
+ /**
+ * Send response body to the client
+ *
+ * @return object Same Response object, for method chaining
+ * @access public
+ */
+ public function send_body()
+ {
echo $this->body;
return $this;
}
-
+
}
\ No newline at end of file |