about summary refs log tree commit diff stats
path: root/classes/Response.php
diff options
context:
space:
mode:
authorAndrew Dolgov <fox@fakecake.org>2026-05-31 09:11:20 +0300
committerAndrew Dolgov <fox@fakecake.org>2026-05-31 09:11:20 +0300
commitb58f0a8f2431040edf94edb21f9c884f20ba6049 (patch)
treeb70055bf14983a59242ae27cdba75f6d39d391a3 /classes/Response.php
parentb76af33e9bfb57b46fb8d8292b614bf9ee2e3c2d (diff)
downloadthe-epube-b58f0a8f2431040edf94edb21f9c884f20ba6049.tar.gz
the-epube-b58f0a8f2431040edf94edb21f9c884f20ba6049.tar.xz
tabs to spaces
Diffstat (limited to 'classes/Response.php')
-rw-r--r--classes/Response.php102
1 files changed, 51 insertions, 51 deletions
diff --git a/classes/Response.php b/classes/Response.php
index 8d32496..ea5e93d 100644
--- a/classes/Response.php
+++ b/classes/Response.php
@@ -2,55 +2,55 @@
 
 class Response
 {
-	private int $status = 200;
-	/** @var array<string, string> */
-	private array $headers = [];
-	private string $body = '';
-	private string $contentType = "text/json";
-
-	public function withStatus(int $code, string $reasonPhrase = ''): self
-	{
-		$clone = clone $this;
-		$clone->status = $code;
-		return $clone;
-	}
-
-	public function withHeader(string $name, string $value): self
-	{
-		$clone = clone $this;
-		$clone->headers[$name] = $value;
-		return $clone;
-	}
-
-	public function getBody(): string
-	{
-		return $this->body;
-	}
-
-	public function withBody(string $body): self
-	{
-		$clone = clone $this;
-		$clone->body = $body;
-		return $clone;
-	}
-
-	public function send(): void
-	{
-		$contentTypeFound = false;
-
-		if ($this->headers) {
-			foreach ($this->headers as $name => $value) {
-				header("$name: $value");
-
-				if (strtolower($name) === "content-type")
-					$contentTypeFound = true;
-			}
-		}
-
-		if (!$contentTypeFound)
-			header("Content-type: {$this->contentType}");
-
-		http_response_code($this->status);
-		echo $this->body;
-	}
+    private int $status = 200;
+    /** @var array<string, string> */
+    private array $headers = [];
+    private string $body = '';
+    private string $contentType = "text/json";
+
+    public function withStatus(int $code, string $reasonPhrase = ''): self
+    {
+        $clone = clone $this;
+        $clone->status = $code;
+        return $clone;
+    }
+
+    public function withHeader(string $name, string $value): self
+    {
+        $clone = clone $this;
+        $clone->headers[$name] = $value;
+        return $clone;
+    }
+
+    public function getBody(): string
+    {
+        return $this->body;
+    }
+
+    public function withBody(string $body): self
+    {
+        $clone = clone $this;
+        $clone->body = $body;
+        return $clone;
+    }
+
+    public function send(): void
+    {
+        $contentTypeFound = false;
+
+        if ($this->headers) {
+            foreach ($this->headers as $name => $value) {
+                header("$name: $value");
+
+                if (strtolower($name) === "content-type")
+                    $contentTypeFound = true;
+            }
+        }
+
+        if (!$contentTypeFound)
+            header("Content-type: {$this->contentType}");
+
+        http_response_code($this->status);
+        echo $this->body;
+    }
 }