public function InputDefinition::addOption in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/symfony/console/Input/InputDefinition.php \Symfony\Component\Console\Input\InputDefinition::addOption()
Adds an InputOption object.
Parameters
InputOption $option An InputOption object:
Throws
\LogicException When option given already exist
1 call to InputDefinition::addOption()
- InputDefinition::addOptions in vendor/
symfony/ console/ Input/ InputDefinition.php - Adds an array of InputOption objects.
File
- vendor/
symfony/ console/ Input/ InputDefinition.php, line 242
Class
- InputDefinition
- A InputDefinition represents a set of valid command line arguments and options.
Namespace
Symfony\Component\Console\InputCode
public function addOption(InputOption $option) {
if (isset($this->options[$option
->getName()]) && !$option
->equals($this->options[$option
->getName()])) {
throw new \LogicException(sprintf('An option named "%s" already exists.', $option
->getName()));
}
if ($option
->getShortcut()) {
foreach (explode('|', $option
->getShortcut()) as $shortcut) {
if (isset($this->shortcuts[$shortcut]) && !$option
->equals($this->options[$this->shortcuts[$shortcut]])) {
throw new \LogicException(sprintf('An option with shortcut "%s" already exists.', $shortcut));
}
}
}
$this->options[$option
->getName()] = $option;
if ($option
->getShortcut()) {
foreach (explode('|', $option
->getShortcut()) as $shortcut) {
$this->shortcuts[$shortcut] = $option
->getName();
}
}
}