Exemple #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));
 }
 /**
  * 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());
 }
Exemple #3
0
 public function testSetDescription()
 {
     $option = new Option('option', null, 0, 'Description');
     $this->assertSame('Description', $option->getDescription());
 }