headers[] = $header; } return $this; } /** * Check if a flash value is present * @param string $key * @return bool */ public function hasFlash(string $key):bool { return array_key_exists($key, $this->flashes); } /** * Add a value to flash * @param string $key * @param mixed $value * @return Response */ public function addFlash(string $key, $value):Response { $this->flashes[$key] = $value; return $this; } /** * Commit Response Data * @param int $response_code */ public function commit(int $response_code=null) { // Set Http response code if (isset($response_code)) { http_response_code($response_code); } // Output headers foreach($this->headers as $header) { header($header); } // Save old URL Path $this->addFlash(self::FLASH_KEY_BACK, $_SERVER['REQUEST_URI']); // Output flashes foreach($this->flashes as $key=>$value) { Session::flash()->set($key, $value); } } }