You are here

public function InputArgument::setDefault in Zircon Profile 8

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

Sets the default value.

Parameters

mixed $default The default value:

Throws

\LogicException When incorrect default value is given

1 call to InputArgument::setDefault()
InputArgument::__construct in vendor/symfony/console/Input/InputArgument.php
Constructor.

File

vendor/symfony/console/Input/InputArgument.php, line 92

Class

InputArgument
Represents a command line argument.

Namespace

Symfony\Component\Console\Input

Code

public function setDefault($default = null) {
  if (self::REQUIRED === $this->mode && null !== $default) {
    throw new \LogicException('Cannot set a default value except for InputArgument::OPTIONAL mode.');
  }
  if ($this
    ->isArray()) {
    if (null === $default) {
      $default = array();
    }
    elseif (!is_array($default)) {
      throw new \LogicException('A default value for an array argument must be an array.');
    }
  }
  $this->default = $default;
}