Skip to content

Commit 546edaf

Browse files
committed
Leverage the match expression
1 parent 64c6828 commit 546edaf

File tree

2 files changed

+12
-21
lines changed

2 files changed

+12
-21
lines changed

Command/LintCommand.php

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -172,16 +172,12 @@ private function validate(string $template, string $file): array
172172

173173
private function display(InputInterface $input, OutputInterface $output, SymfonyStyle $io, array $files)
174174
{
175-
switch ($this->format) {
176-
case 'txt':
177-
return $this->displayTxt($output, $io, $files);
178-
case 'json':
179-
return $this->displayJson($output, $files);
180-
case 'github':
181-
return $this->displayTxt($output, $io, $files, true);
182-
default:
183-
throw new InvalidArgumentException(sprintf('The format "%s" is not supported.', $input->getOption('format')));
184-
}
175+
return match ($this->format) {
176+
'txt' => $this->displayTxt($output, $io, $files),
177+
'json' => $this->displayJson($output, $files),
178+
'github' => $this->displayTxt($output, $io, $files, true),
179+
default => throw new InvalidArgumentException(sprintf('The format "%s" is not supported.', $input->getOption('format'))),
180+
};
185181
}
186182

187183
private function displayTxt(OutputInterface $output, SymfonyStyle $io, array $filesInfo, bool $errorAsGithubAnnotations = false)

Mime/NotificationEmail.php

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -192,17 +192,12 @@ public function getPreparedHeaders(): Headers
192192

193193
private function determinePriority(string $importance): int
194194
{
195-
switch ($importance) {
196-
case self::IMPORTANCE_URGENT:
197-
return self::PRIORITY_HIGHEST;
198-
case self::IMPORTANCE_HIGH:
199-
return self::PRIORITY_HIGH;
200-
case self::IMPORTANCE_MEDIUM:
201-
return self::PRIORITY_NORMAL;
202-
case self::IMPORTANCE_LOW:
203-
default:
204-
return self::PRIORITY_LOW;
205-
}
195+
return match ($importance) {
196+
self::IMPORTANCE_URGENT => self::PRIORITY_HIGHEST,
197+
self::IMPORTANCE_HIGH => self::PRIORITY_HIGH,
198+
self::IMPORTANCE_MEDIUM => self::PRIORITY_NORMAL,
199+
default => self::PRIORITY_LOW,
200+
};
206201
}
207202

208203
private function getExceptionAsString(\Throwable|FlattenException $exception): string

0 commit comments

Comments
 (0)