Returns whether the option takes an optional value.
public isValueOptional ( ) : boolean | ||
Результат | boolean | Returns `true` if the flag {@link VALUE_OPTIONAL} was passed to the constructor. |
/** * Creates an input option for the given option. * * @param Option $option The option. * * @return InputOption The created input option. */ private function adaptOption(Option $option) { $mode = null; if ($option->isMultiValued()) { $mode |= InputOption::VALUE_IS_ARRAY; } if ($option->isValueOptional()) { $mode |= InputOption::VALUE_OPTIONAL; } if ($option->isValueRequired()) { $mode |= InputOption::VALUE_REQUIRED; } return new InputOption($option->getLongName(), $option->getShortName(), $mode, $option->getDescription(), $option->getDefaultValue()); }
public function testMultiValuedWithDefaultValue() { $option = new Option('option', null, Option::MULTI_VALUED, null, array('one', 'two')); $this->assertTrue($option->acceptsValue()); $this->assertTrue($option->isValueRequired()); $this->assertFalse($option->isValueOptional()); $this->assertTrue($option->isMultiValued()); $this->assertSame(array('one', 'two'), $option->getDefaultValue()); }