'text/html; charset=UTF-8' ]; public static function getInstance() : ResponseFactory { if(self::$instance === null) { self::$instance = new self(); } return self::$instance; } private function __construct() { if(defined('DEBUG') && DEBUG) { $this->addHeader('DEBUG', DEBUG); } } public function addHeader(string $name, string $value) : void { $this->headers[$name] = $value; } public function header() : void { if(count($this->headers) > 0) { foreach($this->headers AS $name => $value) { header(sprintf('%s: %s', $name, $value)); } } } public function redirect(string $url) : void { $this->addHeader('Location', $url); $this->header(); exit(); } } ?>