12 namespace Symfony\Component\Console\Input;
49 if (0 === strpos(
$name,
'--')) {
54 throw new \InvalidArgumentException(
'An option name cannot be empty.');
65 $shortcuts = preg_split(
'{(\|)-?}', ltrim(
$shortcut,
'-'));
66 $shortcuts = array_filter($shortcuts);
70 throw new \InvalidArgumentException(
'An option shortcut cannot be empty.');
75 $mode = self::VALUE_NONE;
77 throw new \InvalidArgumentException(sprintf(
'Option mode "%s" is not valid.',
$mode));
86 throw new \InvalidArgumentException(
'Impossible to have an option mode VALUE_IS_ARRAY if the option does not accept a value.');
129 return self::VALUE_REQUIRED === (self::VALUE_REQUIRED &
$this->mode);
139 return self::VALUE_OPTIONAL === (self::VALUE_OPTIONAL &
$this->mode);
149 return self::VALUE_IS_ARRAY === (self::VALUE_IS_ARRAY &
$this->mode);
161 if (self::VALUE_NONE === (self::VALUE_NONE & $this->mode) && null !==
$default) {
162 throw new \LogicException(
'Cannot set a default value when using InputOption::VALUE_NONE mode.');
169 throw new \LogicException(
'A default value for an array option must be an array.');