Adds an option.

@param string $name    The name
@param mixed  $default An optional default value

@throws \InvalidArgumentException
5662
protected function addOption($name, $default = null)
    {
        if (array_key_exists($name, $this->options)) {
            throw new \InvalidArgumentException(sprintf('The option \'%s\' already exists.', $name));
        }

        $this->options[$name] = $default;
    }
912133
public function getAttribute($name, $default = null){
        if(!is_string($name)){
            throw new \InvalidArgumentException(
                "First argument must be of the type string, " . gettype($name) . " given."
            );
        }

        return array_key_exists($name, $this->attributes)
            ? $this->attributes[$name]
            : $default
        ;
    }
795354
protected static function getOption($name, $default = null)
    {
        return isset(self::$options[$name]) ? self::$options[$name] : $default;
    }
97296
public function addOptions($options)
    {
        if (is_string($options)) {
            $this->mergeOptions($this->optionParser->parseString($options));
        } elseif (is_array($options)) {
            $this->mergeOptions($this->optionParser->parseArray($options));
        } else {
            throw new \InvalidArgumentException("Getopt(): argument must be string or array");
        }
    }
1338331
public function addOption($name, $defaultValue)
    {
        if ($this->hasOption($name)) {
            throw new \LogicException(sprintf('The option "%s" already exists.', $name));
        }

        $this->options[$name] = $defaultValue;

        return $this;
    }
9657
public function lBoolOpt(string $name, $default = false): bool
    {
        $val = $this->lOpt($name);

        return \is_bool($val) ? $val : (bool)$default;
    }
813106
public function getOpt(string $name, $default = null)
    {
        if (isset($name{1})) {
            return $this->getLongOpt($name, $default);
        }

        return $this->getShortOpt($name, $default);
    }
709141
protected function addOptionInput($name, $requirement = null, $description = '', $value = null)
    {
        $this->inputs[] = new Option($name, $requirement, $description, $value);
    }
716568
public function getOption($name)
    {
        if (is_string($name)) {
            if (isset($this->options[$name])) {
                return $this->options[$name];
            } else {
                throw new \InvalidArgumentException("An option with the name '$name' doesn't exist.");
            }
        } else {
            throw new \InvalidArgumentException("Invalid type '" . gettype($name) . "' for argument 'name'.");
        }
    }
1141914
public function addOption(OptionInterface $option, $name = null)
    {
        $this->options[$name ?: $option->getName()] = $option;
        if ($option instanceof OptionRegistryAwareInterface) {
            $option->setOptionRegistry($this);
        }

        return $this;
    }
328979
private static function getOption(InputInterface $input, string $name, bool $default = false): bool
    {
        return $input->hasOption($name) ? (bool) $input->getOption($name) : $default;
    }
521809
public function add($name, $value)
    {
        $config = $this->option($name);
        list($key, $extra) = $this->_splitOptionName($name);

        if ($config['array']) {
            $this->_values[$key][$extra][] = $value;
        } else {
            $this->set($name, $value);
        }
        return $this->_values[$key][$extra];
    }
629777
public function setName(string $name) : void
    {
        if (empty($name)) {
            throw new InvalidArgumentException('Empty field name is not allowed');
        }

        $this->_name = $name;
    }
486638
public function customfield($name = null, $default = null)
    {
        $customfields = $this->getAssignedCustomfields();
        foreach ($customfields as $customfield) {
            if ($customfield->getName() === $name) {
                $value = $customfield->setModel($this)->getValue();
                return is_null($value) ? $default : $value;
            }
        }
        return $default;
    }
256124
public function getOption($name, $default = null)
    {
        $data = new Data((array)get_option($this->registry['option_name']));
        return $data->get($name, $default);
    }
22142
public function getOption($name, $default = null)
    {
        if (!isset($this->options[$name])) {
            if (is_callable($default)) {
                $default = call_user_func($default);
            } if ($default instanceof \Exception) {
                throw $default;
            }
            return $default;
        }
        return $this->options[$name];
    }
928165
public function findOption(string $name, $default = null)
    {
        if (array_key_exists($name, $this->options)) {
            return $this->options[$name];
        }

        return $default;
    }