Since: 1.0
Author: Bernhard Schussek (bschussek@gmail.com)
Inheritance: extends RuntimeExceptio\RuntimeException
Esempio n. 1
0
 private function validateCommandName(CommandConfig $config)
 {
     $name = $config->getName();
     if (!$name) {
         throw CannotAddCommandException::nameEmpty();
     }
     if ($this->commands->contains($name)) {
         throw CannotAddCommandException::nameExists($name);
     }
 }
Esempio n. 2
0
 private function validateSubCommandName(SubCommandConfig $config)
 {
     $name = $config->getName();
     if (!$name) {
         throw CannotAddCommandException::nameEmpty();
     }
     if ($this->subCommands->contains($name)) {
         throw CannotAddCommandException::nameExists($name);
     }
     if ($config instanceof OptionCommandConfig) {
         if ($this->argsFormat->hasOption($name)) {
             throw CannotAddCommandException::optionExists($name);
         }
         if ($shortName = $config->getShortName()) {
             if ($this->subCommands->contains($shortName)) {
                 throw CannotAddCommandException::nameExists($name);
             }
             if ($this->argsFormat->hasOption($shortName)) {
                 throw CannotAddCommandException::optionExists($shortName);
             }
         }
     }
 }