Skip to content

Commit 973b54e

Browse files
authored
[10.x] Use match expression in resolveSynchronousFake (#47540)
* [10.x] Use `match` expression in `resolveSynchronousFake` * StyleCI fix
1 parent b4ab629 commit 973b54e

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

src/Illuminate/Process/PendingProcess.php

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -361,17 +361,15 @@ protected function resolveSynchronousFake(string $command, Closure $fake)
361361

362362
if (is_string($result) || is_array($result)) {
363363
return (new FakeProcessResult(output: $result))->withCommand($command);
364-
} elseif ($result instanceof ProcessResult) {
365-
return $result;
366-
} elseif ($result instanceof FakeProcessResult) {
367-
return $result->withCommand($command);
368-
} elseif ($result instanceof FakeProcessDescription) {
369-
return $result->toProcessResult($command);
370-
} elseif ($result instanceof FakeProcessSequence) {
371-
return $this->resolveSynchronousFake($command, fn () => $result());
372364
}
373365

374-
throw new LogicException('Unsupported synchronous process fake result provided.');
366+
return match (true) {
367+
$result instanceof ProcessResult => $result,
368+
$result instanceof FakeProcessResult => $result->withCommand($command),
369+
$result instanceof FakeProcessDescription => $result->toProcessResult($command),
370+
$result instanceof FakeProcessSequence => $this->resolveSynchronousFake($command, fn () => $result()),
371+
default => throw new LogicException('Unsupported synchronous process fake result provided.'),
372+
};
375373
}
376374

377375
/**

0 commit comments

Comments
 (0)