isValueRequired() 공개 메소드

Returns whether the option requires a value.
public isValueRequired ( ) : boolean
리턴 boolean Returns `true` if the flag {@link VALUE_REQUIRED} 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());
 }
예제 #2
0
 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());
 }