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

nameEmpty() public static méthode

Creates an exception for the code {@link NAME_EMPTY}.
public static nameEmpty ( Exception $cause = null ) : static
$cause Exception The exception that caused this exception.
Résultat static The created exception.
    public static function nameEmpty(Exception $cause = null)
    {
        return new static('The command name must be set.', self::NAME_EMPTY, $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::nameEmpty