request = $_POST; $this->query = $_GET; } /** * Get GET input * * @param string $key * @param mixed $default * @return mixed */ public function get($key, $default = null) { if (!empty($this->query[$key])) { return $this->query[$key]; } return $default; } /** * Get POST input * * @param string $key * @param mixed $default * @return mixed */ public function post($key, $default = null) { if (!empty($this->request[$key])) { return $this->request[$key]; } return $default; } /** * Get input data * * @param string $key * @param mixed $default * @return mixed */ public function input($key, $default = null) { $data = $this->request + $this->query; if (isset($data[$key])) { return $data[$key]; } return $default; } /** * Checks if the input exists * * @param string $key * @return bool */ public function has($key) { $data = $this->request + $this->query; return isset($data[$key]); } /** * @return self * @throws ErrorException */ public static function getInstance() { if (!self::$instance instanceof self) { throw new ErrorException('Request not initialized'); } return self::$instance; } /** * @param self $instance */ public static function setInstance($instance) { self::$instance = $instance; } }