public function addOption(Option $option)
    {
        $longName = $option->getLongName();
        $shortName = $option->getShortName();

        if ($this->hasOption($longName) || $this->hasCommandOption($longName)) {
            throw CannotAddOptionException::existsAlready($longName);
        }

        if ($shortName && ($this->hasOption($shortName) || $this->hasCommandOption($shortName))) {
            throw CannotAddOptionException::existsAlready($shortName);
        }

        $this->options[$longName] = $option;

        if ($shortName) {
            $this->optionsByShortName[$shortName] = $option;
        }

        return $this;
    }
public function addOption(Option $option)
    {
        $longName = $option->getLongName();
        $shortName = $option->getShortName();

        if ($this->hasOption($longName) || $this->hasCommandOption($longName)) {
            throw CannotAddOptionException::existsAlready($longName);
        }

        if ($shortName && ($this->hasOption($shortName) || $this->hasCommandOption($shortName))) {
            throw CannotAddOptionException::existsAlready($shortName);
        }

        $this->options[$longName] = $option;

        if ($shortName) {
            $this->optionsByShortName[$shortName] = $option;
        }

        return $this;
    }
public function addOption ( Option $ option ) { $ longName = $ option -> getLongName ( ) ; $ shortName = $ option -> getShortName ( ) ; if ( $ this -> hasOption ( $ longName ) || $ this -> hasCommandOption ( $ longName ) ) { throw CannotAddOptionException :: existsAlready ( $ longName ) ; } if ( $ shortName && ( $ this -> hasOption ( $ shortName ) || $ this -> hasCommandOption ( $ shortName ) ) ) { throw CannotAddOptionException :: existsAlready ( $ shortName ) ; } $ this -> options [ $ longName ] = $ option ; if ( $ shortName ) { $ this -> optionsByShortName [ $ shortName ] = $ option ; } return $ this ; }
Adds an option at the end of the options list.

The existing options stored in the builder are preserved.

@param Option $option The option to add.

@return static The current instance.

@throws CannotAddOptionException If the option cannot be added.

@see addOptions()
Adds an option at the end of the options list .