From 6d8b20475b4d744764410178854451101468aef7 Mon Sep 17 00:00:00 2001 From: Juuso Lapinlampi Date: Tue, 29 Sep 2015 22:02:55 +0000 Subject: Sort Response code lines alphabetically again This commit improves readability. --- static/classes/Response.class.php | 47 +++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 24 deletions(-) (limited to 'static/classes') diff --git a/static/classes/Response.class.php b/static/classes/Response.class.php index cb34ab4..bfc708a 100755 --- a/static/classes/Response.class.php +++ b/static/classes/Response.class.php @@ -41,14 +41,14 @@ class Response header('Content-Type: text/html; charset=UTF-8'); $this->type = $response_type; break; - case 'text': - header('Content-Type: text/plain; charset=UTF-8'); - $this->type = $response_type; - break; case 'json': header('Content-Type: application/json; charset=UTF-8'); $this->type = $response_type; break; + case 'text': + header('Content-Type: text/plain; charset=UTF-8'); + $this->type = $response_type; + break; default: http_response_code(400); echo 'Invalid response type. Valid options are: csv, html, text, json.'; @@ -67,12 +67,12 @@ class Response case 'html': $response = $this->html_error($code, $desc); break; - case 'text': - $response = $this->text_error($code, $desc); - break; case 'json': $response = $this->json_error($code, $desc); break; + case 'text': + $response = $this->text_error($code, $desc); + break; } http_response_code($code); @@ -90,12 +90,12 @@ class Response case 'html': $response = $this->html_success($files); break; - case 'text': - $response = $this->text_success($files); - break; case 'json': $response = $this->json_success($files); break; + case 'text': + $response = $this->text_success($files); + break; } http_response_code(200); @@ -134,20 +134,6 @@ class Response return $result; } - private static function text_error($code, $description) - { - return 'ERROR: ('.$code.') '.$description; - } - - private static function text_success($files) - { - foreach ($files as $file) { - $result .= $file['url']."\n"; - } - - return $result; - } - private static function json_error($code, $description) { return json_encode(array( @@ -164,4 +150,17 @@ class Response 'files' => $files, )); } + private static function text_error($code, $description) + { + return 'ERROR: ('.$code.') '.$description; + } + + private static function text_success($files) + { + foreach ($files as $file) { + $result .= $file['url']."\n"; + } + + return $result; + } } -- cgit v1.2.3