Skip to content

Commit

Permalink
pref: formatStatus
Browse files Browse the repository at this point in the history
  • Loading branch information
jiannei committed Oct 11, 2023
1 parent 7bdfaf0 commit d7f63e5
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/Support/Format.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,15 +152,12 @@ protected function formatMessage(int $code, ?string $message): ?string
protected function formatStatus(int $code): string
{
$statusCode = $this->formatStatusCode($code);
if ($statusCode >= 400 && $statusCode <= 499) {// client error
$status = 'error';
} elseif ($statusCode >= 500 && $statusCode <= 599) {// service error
$status = 'fail';
} else {
$status = 'success';
}

return $status;
return match(true) {
($statusCode >= 400 && $statusCode <= 499) => 'error',// client error
($statusCode >= 500 && $statusCode <= 599) => 'fail',// service error
default => 'success'
};
}

/**
Expand Down

0 comments on commit d7f63e5

Please sign in to comment.