From 94b8efb6f401159d056a2cbb7546e0649fe928c1 Mon Sep 17 00:00:00 2001 From: flashwave Date: Wed, 27 May 2020 13:47:52 +0000 Subject: [PATCH] Allow spaces instead of underscores for new migration command. --- src/Console/CommandArgs.php | 6 +++++- src/Console/Commands/NewMigrationCommand.php | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Console/CommandArgs.php b/src/Console/CommandArgs.php index 5d0efda3..c97c1ad7 100644 --- a/src/Console/CommandArgs.php +++ b/src/Console/CommandArgs.php @@ -9,7 +9,11 @@ class CommandArgs { } public function getArgs(): array { - return $this->args; + return array_slice($this->args, 2); + } + + public function getArgCount(): int { + return count($this->args) - 2; } public function getCommand(): string { diff --git a/src/Console/Commands/NewMigrationCommand.php b/src/Console/Commands/NewMigrationCommand.php index 385709f6..f7c5d707 100644 --- a/src/Console/Commands/NewMigrationCommand.php +++ b/src/Console/Commands/NewMigrationCommand.php @@ -33,7 +33,7 @@ MIG; } public function dispatch(CommandArgs $args): void { - $name = trim($args->getArg(0)); + $name = str_replace(' ', '_', implode(' ', $args->getArgs())); if(empty($name)) { echo 'Specify a migration name.' . PHP_EOL;