Skip to content

Commit

Permalink
[10.x] Use match expression in resolveSynchronousFake (#47540)
Browse files Browse the repository at this point in the history
* [10.x] Use `match` expression in `resolveSynchronousFake`

* StyleCI fix
  • Loading branch information
osbre authored Jun 23, 2023
1 parent b4ab629 commit 973b54e
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/Illuminate/Process/PendingProcess.php
Original file line number Diff line number Diff line change
Expand Up @@ -361,17 +361,15 @@ protected function resolveSynchronousFake(string $command, Closure $fake)

if (is_string($result) || is_array($result)) {
return (new FakeProcessResult(output: $result))->withCommand($command);
} elseif ($result instanceof ProcessResult) {
return $result;
} elseif ($result instanceof FakeProcessResult) {
return $result->withCommand($command);
} elseif ($result instanceof FakeProcessDescription) {
return $result->toProcessResult($command);
} elseif ($result instanceof FakeProcessSequence) {
return $this->resolveSynchronousFake($command, fn () => $result());
}

throw new LogicException('Unsupported synchronous process fake result provided.');
return match (true) {
$result instanceof ProcessResult => $result,
$result instanceof FakeProcessResult => $result->withCommand($command),
$result instanceof FakeProcessDescription => $result->toProcessResult($command),
$result instanceof FakeProcessSequence => $this->resolveSynchronousFake($command, fn () => $result()),
default => throw new LogicException('Unsupported synchronous process fake result provided.'),
};
}

/**
Expand Down

0 comments on commit 973b54e

Please sign in to comment.