You are here

protected function TextDescriptor::describeInputOption in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/symfony/console/Descriptor/TextDescriptor.php \Symfony\Component\Console\Descriptor\TextDescriptor::describeInputOption()

Describes an InputOption instance.

Parameters

InputOption $option:

array $options:

Return value

string|mixed

Overrides Descriptor::describeInputOption

1 call to TextDescriptor::describeInputOption()
TextDescriptor::describeInputDefinition in vendor/symfony/console/Descriptor/TextDescriptor.php
Describes an InputDefinition instance.

File

vendor/symfony/console/Descriptor/TextDescriptor.php, line 55

Class

TextDescriptor
Text descriptor.

Namespace

Symfony\Component\Console\Descriptor

Code

protected function describeInputOption(InputOption $option, array $options = array()) {
  if ($option
    ->acceptValue() && null !== $option
    ->getDefault() && (!is_array($option
    ->getDefault()) || count($option
    ->getDefault()))) {
    $default = sprintf('<comment> [default: %s]</comment>', $this
      ->formatDefaultValue($option
      ->getDefault()));
  }
  else {
    $default = '';
  }
  $value = '';
  if ($option
    ->acceptValue()) {
    $value = '=' . strtoupper($option
      ->getName());
    if ($option
      ->isValueOptional()) {
      $value = '[' . $value . ']';
    }
  }
  $totalWidth = isset($options['total_width']) ? $options['total_width'] : $this
    ->calculateTotalWidthForOptions(array(
    $option,
  ));
  $synopsis = sprintf('%s%s', $option
    ->getShortcut() ? sprintf('-%s, ', $option
    ->getShortcut()) : '    ', sprintf('--%s%s', $option
    ->getName(), $value));
  $spacingWidth = $totalWidth - strlen($synopsis) + 2;
  $this
    ->writeText(sprintf('  <info>%s</info>%s%s%s%s', $synopsis, str_repeat(' ', $spacingWidth), preg_replace('/\\s*[\\r\\n]\\s*/', "\n" . str_repeat(' ', $totalWidth + 17), $option
    ->getDescription()), $default, $option
    ->isArray() ? '<comment> (multiple values allowed)</comment>' : ''), $options);
}