From b58ac08dd03930dd30899a88fb965d0c186fc9da Mon Sep 17 00:00:00 2001 From: "as2252258@163.com" Date: Wed, 4 Aug 2021 02:55:38 +0800 Subject: [PATCH] modify --- HttpServer/Http/Response.php | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/HttpServer/Http/Response.php b/HttpServer/Http/Response.php index 6108e002..ad641eca 100644 --- a/HttpServer/Http/Response.php +++ b/HttpServer/Http/Response.php @@ -58,7 +58,7 @@ class Response extends HttpService */ public function setFormat($format): static { - if (empty($format)){ + if (empty($format)) { return $this; } $this->format = $format; @@ -144,13 +144,11 @@ class Response extends HttpService */ public function getResponseFormat(): string { - if ($this->format == self::HTML) { - return 'text/html;charset=utf-8'; - } else if ($this->format == self::XML) { - return 'application/xml;charset=utf-8'; - } else { - return 'application/json;charset=utf-8'; - } + return match ($this->format) { + Response::HTML => 'text/html;charset=utf-8', + Response::XML => 'application/xml;charset=utf-8', + default => 'application/json;charset=utf-8', + }; }