about summary refs log tree commit diff stats
path: root/classes/Handler/PaginationHandler.php
diff options
context:
space:
mode:
Diffstat (limited to 'classes/Handler/PaginationHandler.php')
-rw-r--r--classes/Handler/PaginationHandler.php112
1 files changed, 56 insertions, 56 deletions
diff --git a/classes/Handler/PaginationHandler.php b/classes/Handler/PaginationHandler.php
index 54421d5..a027c58 100644
--- a/classes/Handler/PaginationHandler.php
+++ b/classes/Handler/PaginationHandler.php
@@ -10,71 +10,71 @@ use Response;
 
 class PaginationHandler implements RequestHandlerInterface, AuthRequired
 {
-	private function handleGet(int $bookid): Response
-	{
-		if ($bookid) {
-			$pag = ORM::for_table('epube_pagination')
-				->where('bookid', $bookid)
-				->find_one();
+    private function handleGet(int $bookid): Response
+    {
+        if ($bookid) {
+            $pag = ORM::for_table('epube_pagination')
+                ->where('bookid', $bookid)
+                ->find_one();
 
-			if ($pag) {
-				return (new Response())->withBody($pag->pagination);
-			}
-		}
+            if ($pag) {
+                return (new Response())->withBody($pag->pagination);
+            }
+        }
 
-		return (new Response())
-			->withStatus(404)
-			->withBody(json_encode(["error" => "File not found."]));
-	}
+        return (new Response())
+            ->withStatus(404)
+            ->withBody(json_encode(["error" => "File not found."]));
+    }
 
-	private function handleStore(int $bookid, ?string $payload): Response
-	{
-		if ($bookid && $payload) {
-			$pag = ORM::for_table('epube_pagination')
-				->where('bookid', $bookid)
-				->find_one();
+    private function handleStore(int $bookid, ?string $payload): Response
+    {
+        if ($bookid && $payload) {
+            $pag = ORM::for_table('epube_pagination')
+                ->where('bookid', $bookid)
+                ->find_one();
 
-			if (!$pag) {
-				$pag = ORM::for_table('epube_pagination')->create();
-				$pag->bookid = $bookid;
-			}
+            if (!$pag) {
+                $pag = ORM::for_table('epube_pagination')->create();
+                $pag->bookid = $bookid;
+            }
 
-			$pag->pagination = $payload;
-			$pag->total_pages = 100;
-			$pag->save();
-		}
+            $pag->pagination = $payload;
+            $pag->total_pages = 100;
+            $pag->save();
+        }
 
-		return new Response();
-	}
+        return new Response();
+    }
 
-	private function handleDelete(int $bookid): Response
-	{
-		if ($bookid) {
-			$pag = ORM::for_table('epube_pagination')
-				->where('bookid', $bookid)
-				->find_one();
+    private function handleDelete(int $bookid): Response
+    {
+        if ($bookid) {
+            $pag = ORM::for_table('epube_pagination')
+                ->where('bookid', $bookid)
+                ->find_one();
 
-			if ($pag) {
-				$pag->delete();
-				return new Response();
-			}
-		}
+            if ($pag) {
+                $pag->delete();
+                return new Response();
+            }
+        }
 
-		return (new Response())
-			->withStatus(404)
-			->withBody(json_encode(["error" => "Not found."]));
-	}
+        return (new Response())
+            ->withStatus(404)
+            ->withBody(json_encode(["error" => "Not found."]));
+    }
 
-	public function handle(Request $request): Response
-	{
-		$subOp = $request->getAttribute('op', '');
-		$bookid = (int) $request->getAttribute('id');
+    public function handle(Request $request): Response
+    {
+        $subOp = $request->getAttribute('op', '');
+        $bookid = (int) $request->getAttribute('id');
 
-		return match ($subOp) {
-			'getpagination'   => $this->handleGet($bookid),
-			'storepagination' => $this->handleStore($bookid, $request->getAttribute('payload')),
-			'deletepagination' => $this->handleDelete($bookid),
-			default           => (new Response())->withStatus(404)->withBody(json_encode(["error" => "Not found."])),
-		};
-	}
+        return match ($subOp) {
+            'getpagination'   => $this->handleGet($bookid),
+            'storepagination' => $this->handleStore($bookid, $request->getAttribute('payload')),
+            'deletepagination' => $this->handleDelete($bookid),
+            default           => (new Response())->withStatus(404)->withBody(json_encode(["error" => "Not found."])),
+        };
+    }
 }