Skip to content

Commit

Permalink
Simplify pattern and fix mistakes.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Dec 18, 2018
1 parent 62f328e commit b05bc8d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
5 changes: 2 additions & 3 deletions src/Console/CommandCollection.php
Expand Up @@ -64,10 +64,9 @@ public function add($name, $command)
"Cannot use '$class' for command '$name' it is not a subclass of Cake\Console\Shell or Cake\Console\Command."
);
}
if (!preg_match('/^[\p{L}\p{N}\-_:.]+(?:(?: [\p{L}\p{N}\-_:.]+){1,2})?$/ui', $name)) {
if (!preg_match('/^[^\s]+(?:(?: [^\s]+){1,2})?$/ui', $name)) {
throw new InvalidArgumentException(
"The command name `{$name}` is invalid. " .
'Names must use only letters/numbers + punctuation characters and be 3 words or fewer.'
"The command name `{$name}` is invalid. Names can only be a maximum of three words."
);
}

Expand Down
3 changes: 2 additions & 1 deletion tests/TestCase/Console/CommandCollectionTest.php
Expand Up @@ -20,6 +20,7 @@
use Cake\Shell\I18nShell;
use Cake\Shell\RoutesShell;
use Cake\TestSuite\TestCase;
use InvalidArgumentException;
use stdClass;
use TestApp\Command\DemoCommand;

Expand Down Expand Up @@ -164,7 +165,7 @@ public function invalidNameProvider()
public function testAddCommandInvalidName($name)
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('Invalid command name');
$this->expectExceptionMessage("The command name `$name` is invalid.");
$collection = new CommandCollection();
$collection->add($name, DemoCommand::class);
}
Expand Down

0 comments on commit b05bc8d

Please sign in to comment.