Skip to content

Commit

Permalink
Bail early (#785)
Browse files Browse the repository at this point in the history
* Bail early

Also, use whitespace to make `return` statements more visible.

* CS
  • Loading branch information
ravage84 authored Dec 6, 2024
1 parent f209d07 commit 7cb5f6c
Showing 1 changed file with 19 additions and 18 deletions.
37 changes: 19 additions & 18 deletions src/MigrationsPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,27 +130,28 @@ public function console(CommandCollection $commands): CommandCollection
$commands->addMany($found);

return $commands;
} else {
if (class_exists(SimpleBakeCommand::class)) {
$found = $commands->discoverPlugin($this->getName());
}

return $commands->addMany($found);
}
$found = [];
// Convert to a method and use config to toggle command names.
foreach ($this->migrationCommandsList as $class) {
$name = $class::defaultName();
// If the short name has been used, use the full name.
// This allows app commands to have name preference.
// and app commands to overwrite migration commands.
if (!$commands->has($name)) {
$found[$name] = $class;
}
// full name
$found['migrations.' . $name] = $class;
}
if (class_exists(SimpleBakeCommand::class)) {
$found = $commands->discoverPlugin($this->getName());

return $commands->addMany($found);
}

$found = [];
// Convert to a method and use config to toggle command names.
foreach ($this->migrationCommandsList as $class) {
$name = $class::defaultName();
// If the short name has been used, use the full name.
// This allows app commands to have name preference.
// and app commands to overwrite migration commands.
if (!$commands->has($name)) {
$found[$name] = $class;
}
// full name
$found['migrations.' . $name] = $class;
}

return $commands->addMany($found);
}
}

0 comments on commit 7cb5f6c

Please sign in to comment.