You are here

private function ArrayInput::addLongOption in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/console/Input/ArrayInput.php \Symfony\Component\Console\Input\ArrayInput::addLongOption()

Adds a long option value.

Parameters

string $name The long option key:

mixed $value The value for the option:

Throws

\InvalidArgumentException When option given doesn't exist

\InvalidArgumentException When a required value is missing

2 calls to ArrayInput::addLongOption()
ArrayInput::addShortOption in vendor/symfony/console/Input/ArrayInput.php
Adds a short option value.
ArrayInput::parse in vendor/symfony/console/Input/ArrayInput.php
Processes command line arguments.

File

vendor/symfony/console/Input/ArrayInput.php, line 172

Class

ArrayInput
ArrayInput represents an input provided as an array.

Namespace

Symfony\Component\Console\Input

Code

private function addLongOption($name, $value) {
  if (!$this->definition
    ->hasOption($name)) {
    throw new \InvalidArgumentException(sprintf('The "--%s" option does not exist.', $name));
  }
  $option = $this->definition
    ->getOption($name);
  if (null === $value) {
    if ($option
      ->isValueRequired()) {
      throw new \InvalidArgumentException(sprintf('The "--%s" option requires a value.', $name));
    }
    $value = $option
      ->isValueOptional() ? $option
      ->getDefault() : true;
  }
  $this->options[$name] = $value;
}