From e884ffd4c8046c3fd991ce56eee76b369aabc338 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= <91878298+come-nc@users.noreply.github.com> Date: Thu, 11 Jan 2024 11:26:24 +0100 Subject: [PATCH] Use match statement in richToParsed implementation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Benjamin Gaussorgues Signed-off-by: Côme Chilliet --- core/Command/SetupChecks.php | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/core/Command/SetupChecks.php b/core/Command/SetupChecks.php index ca39948de4e..e6e54fbcf22 100644 --- a/core/Command/SetupChecks.php +++ b/core/Command/SetupChecks.php @@ -59,13 +59,11 @@ class SetupChecks extends Base { throw new \InvalidArgumentException("Invalid rich object, {$requiredField} field is missing"); } } - if ($parameter['type'] === 'user') { - $replacements[] = '@' . $parameter['name']; - } elseif ($parameter['type'] === 'file') { - $replacements[] = $parameter['path'] ?? $parameter['name']; - } else { - $replacements[] = $parameter['name']; - } + $replacements[] = match($parameter['type']) { + 'user' => '@' . $parameter['name'], + 'file' => $parameter['path'] ?? $parameter['name'], + default => $parameter['name'], + }; } return str_replace($placeholders, $replacements, $message); }