Webmozart\Console\Api\Command\CannotAddCommandException::nameExists PHP Méthode

nameExists() public static méthode

Creates an exception for the code {@link NAME_EXISTS}.
public static nameExists ( string $name, Exception $cause = null ) : static
$name string The command name.
$cause Exception The exception that caused this exception.
Résultat static The created exception.
    public static function nameExists($name, Exception $cause = null)
    {
        return new static(sprintf('A command named "%s" exists already.', $name), self::NAME_EXISTS, $cause);
    }

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\CannotAddCommandException::nameExists