From bc608e6324bfe2869d48ac0fafb7f83905bf2d27 Mon Sep 17 00:00:00 2001 From: Fariz Luqman Date: Thu, 11 Aug 2016 13:25:49 +0800 Subject: [PATCH] Added response class --- src/Response.php | 70 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 src/Response.php diff --git a/src/Response.php b/src/Response.php new file mode 100644 index 0000000..755685b --- /dev/null +++ b/src/Response.php @@ -0,0 +1,70 @@ + + * @copyright 2016 Studio Nexus + * @license MIT + * @version Release: 0.3.0 + * @link https://www.studionexus.co/php/damnstupidsimple + */ +namespace Core; + +class Response { + + private static $_instance = null; + private $data = []; + + private function __construct(){ + $this->data = array_merge($_GET, $_POST); + } + + static function redirect($html_location, $time = 0){ + if(!headers_sent()) + { + header("Location:".$html_location, TRUE, 302); + exit; + } + exit(''); + } + + static function get($key = null){ + if (self::$_instance === null) { + self::$_instance = new self; + } + + return self::$_instance->returnResponse($key); + } + + function returnResponse($key = null){ + if($key !== null){ + if(!isset($this->data[$key])){ + return null; + } + return $this->data[$key]; + }else{ + return $this->data; + } + } +} \ No newline at end of file