Webmozart\Console\Api\Command\CommandCollection::contains PHP Method

contains() public method

Returns whether the collection contains a command with the given name.
public contains ( string $name ) : boolean
$name string The name of the command.
return boolean Returns `true` if the collection contains a command with that name and `false` otherwise.
    public function contains($name)
    {
        return isset($this->commands[$name]) || isset($this->shortNameIndex[$name]) || isset($this->aliasIndex[$name]);
    }

Usage Example

 private function validateCommandName(CommandConfig $config)
 {
     $name = $config->getName();
     if (!$name) {
         throw CannotAddCommandException::nameEmpty();
     }
     if ($this->commands->contains($name)) {
         throw CannotAddCommandException::nameExists($name);
     }
 }
All Usage Examples Of Webmozart\Console\Api\Command\CommandCollection::contains