Skip to content

Commit 0095ead

Browse files
committed
formatting. extract method
1 parent cd87c01 commit 0095ead

File tree

1 file changed

+27
-13
lines changed

1 file changed

+27
-13
lines changed

src/Illuminate/Console/Application.php

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -172,19 +172,7 @@ public static function forgetBootstrappers()
172172
*/
173173
public function call($command, array $parameters = [], $outputBuffer = null)
174174
{
175-
if (is_subclass_of($command, SymfonyCommand::class)) {
176-
$callingClass = true;
177-
$command = $this->laravel->make($command)->getName();
178-
}
179-
180-
if (! isset($callingClass) && empty($parameters)) {
181-
$command = $this->getCommandName(
182-
$input = new StringInput($command)
183-
);
184-
} else {
185-
array_unshift($parameters, $command);
186-
$input = new ArrayInput($parameters);
187-
}
175+
[$command, $input] = $this->parseCommand($command, $parameters);
188176

189177
if (! $this->has($command)) {
190178
throw new CommandNotFoundException(sprintf('The command "%s" does not exist.', $command));
@@ -201,6 +189,32 @@ public function call($command, array $parameters = [], $outputBuffer = null)
201189
return $result;
202190
}
203191

192+
/**
193+
* Parse the incoming Artisan command and its input.
194+
*
195+
* @param string $command
196+
* @param array $parameters
197+
* @return array
198+
*/
199+
protected function parseCommand($command, $parameters)
200+
{
201+
if (is_subclass_of($command, SymfonyCommand::class)) {
202+
$callingClass = true;
203+
204+
$command = $this->laravel->make($command)->getName();
205+
}
206+
207+
if (! isset($callingClass) && empty($parameters)) {
208+
$command = $this->getCommandName($input = new StringInput($command));
209+
} else {
210+
array_unshift($parameters, $command);
211+
212+
$input = new ArrayInput($parameters);
213+
}
214+
215+
return [$command, $input ?? null];
216+
}
217+
204218
/**
205219
* Get the output for the last run command.
206220
*

0 commit comments

Comments
 (0)