]> jfr.im git - uguu.git/commitdiff
update
authorGo Johansson (neku) <redacted>
Fri, 22 Jul 2022 05:03:13 +0000 (07:03 +0200)
committerGo Johansson (neku) <redacted>
Fri, 22 Jul 2022 05:03:13 +0000 (07:03 +0200)
src/Classes/Response.php
src/Classes/Upload.php

index 974c24e87343747bad2f93aca38ebab867f47739..17b216cddea24843bf30eab4846ed5c262d640ae 100644 (file)
@@ -58,22 +58,12 @@ class Response
 
     public function error($code, $desc): void
     {
-        $response = null;
-
-        switch ($this->type) {
-            case 'csv':
-                $response = $this->csvError($desc);
-                break;
-            case 'html':
-                $response = $this->htmlError($code, $desc);
-                break;
-            case 'json':
-                $response = $this->jsonError($code, $desc);
-                break;
-            case 'text':
-                $response = $this->textError($code, $desc);
-                break;
-        }
+        $response = match ($this->type) {
+            'csv' => $this->csvError($desc),
+            'html' => $this->htmlError($code, $desc),
+            'json' => $this->jsonError($code, $desc),
+            'text' => $this->textError($code, $desc),
+        };
         http_response_code($code);
         echo $response;
     }
@@ -105,22 +95,12 @@ class Response
 
     public function send($files): void
     {
-        $response = null;
-
-        switch ($this->type) {
-            case 'csv':
-                $response = $this->csvSuccess($files);
-                break;
-            case 'html':
-                $response = $this->htmlSuccess($files);
-                break;
-            case 'json':
-                $response = $this->jsonSuccess($files);
-                break;
-            case 'text':
-                $response = $this->textSuccess($files);
-                break;
-        }
+        $response = match ($this->type) {
+            'csv' => $this->csvSuccess($files),
+            'html' => $this->htmlSuccess($files),
+            'json' => $this->jsonSuccess($files),
+            'text' => $this->textSuccess($files),
+        };
 
         http_response_code(200); // "200 OK". Success.
         echo $response;
index 7623e91cce496feb9d9c73e2dd196d6bdf7b8c68..17e79f8301f53e42d0eea7d5a16eca071f3fa22c 100644 (file)
@@ -86,11 +86,11 @@ class Upload extends Response
             $this->Connector->checkFileBlacklist($this->FILE_INFO);
         }
 
-        if ($this->Connector->CONFIG['FILTER_MODE'] and empty($this->FILE_INFO['EXTENSION'])) {
+        if ($this->Connector->CONFIG['FILTER_MODE'] && empty($this->FILE_INFO['EXTENSION'])) {
             $this->checkMimeBlacklist();
         }
 
-        if ($this->Connector->CONFIG['FILTER_MODE'] and !empty($this->FILE_INFO['EXTENSION'])) {
+        if ($this->Connector->CONFIG['FILTER_MODE'] && !empty($this->FILE_INFO['EXTENSION'])) {
             $this->checkMimeBlacklist();
             $this->checkExtensionBlacklist();
         }