acceptsValue() 공개 메소드

Returns whether the option accepts a value.
public acceptsValue ( ) : boolean
리턴 boolean Returns `true` if a value flag other than {@link VALUE_NONE} was passed to the constructor.
예제 #1
0
 /**
  * Renders an option.
  *
  * @param BlockLayout $layout The layout.
  * @param Option      $option The option to render.
  */
 protected function renderOption(BlockLayout $layout, Option $option)
 {
     $description = $option->getDescription();
     $defaultValue = $option->getDefaultValue();
     if ($option->isLongNamePreferred()) {
         $preferredName = '--' . $option->getLongName();
         $alternativeName = $option->getShortName() ? '-' . $option->getShortName() : null;
     } else {
         $preferredName = '-' . $option->getShortName();
         $alternativeName = '--' . $option->getLongName();
     }
     $name = '<c1>' . $preferredName . '</c1>';
     if ($alternativeName) {
         $name .= sprintf(' (%s)', $alternativeName);
     }
     if ($option->acceptsValue() && null !== $defaultValue && (!is_array($defaultValue) || count($defaultValue))) {
         $description .= sprintf(' <b>(default: %s)</b>', $this->formatValue($defaultValue));
     }
     if ($option->isMultiValued()) {
         $description .= ' <b>(multiple values allowed)</b>';
     }
     $layout->add(new LabeledParagraph($name, $description));
 }
예제 #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());
 }