Skip to content

Commit

Permalink
Replace 'switch' with 'match' expression
Browse files Browse the repository at this point in the history
  • Loading branch information
caendesilva committed Nov 8, 2023
1 parent 9f4a3cb commit ce68146
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions packages/realtime-compiler/src/Http/DashboardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,20 +109,12 @@ protected function handlePostRequest(): JsonResponse
$action = $this->request->data['action'] ?? $this->abort(400, 'Must provide action');
$action = $actions[$action] ?? $this->abort(403, "Invalid action '$action'");

switch ($action) {
case 'openInExplorer':
$this->openInExplorer();
break;
case 'openPageInEditor':
$this->openPageInEditor();
break;
case 'openMediaFileInEditor':
$this->openMediaFileInEditor();
break;
case 'createPage':
$this->createPage();
break;
}
match ($action) {
'openInExplorer' => $this->openInExplorer(),
'openPageInEditor' => $this->openPageInEditor(),
'openMediaFileInEditor' => $this->openMediaFileInEditor(),
'createPage' => $this->createPage(),
};

return $this->response ?? new JsonResponse(200, 'OK', [
'message' => 'Action completed successfully',
Expand Down

0 comments on commit ce68146

Please sign in to comment.