src/Console/Option/OptionCollection.php
public function addOption(Option $spec)
    {
        $this->data[$spec->getId()] = $spec;
        if ($spec->long) {
            if (isset($this->longOptions[$spec->long])) {
                throw new OptionConflictException('Option conflict: --' . $spec->long . ' is already defined.');
            }
            $this->longOptions[$spec->long] = $spec;
        }
        if ($spec->short) {
            if (isset($this->shortOptions[$spec->short])) {
                throw new OptionConflictException('Option conflict: -' . $spec->short . ' is already defined.');
            }
            $this->shortOptions[$spec->short] = $spec;
        }
        $this->options[] = $spec;
        if (!$spec->long && !$spec->short) {
            throw new InvalidArgumentException('Neither long option name nor short name is not given.');
        }
    }
public function addOption(Option $spec)
    {
        $this->data[$spec->getId()] = $spec;
        if ($spec->long) {
            if (isset($this->longOptions[$spec->long])) {
                throw new OptionConflictException('Option conflict: --' . $spec->long . ' is already defined.');
            }
            $this->longOptions[$spec->long] = $spec;
        }
        if ($spec->short) {
            if (isset($this->shortOptions[$spec->short])) {
                throw new OptionConflictException('Option conflict: -' . $spec->short . ' is already defined.');
            }
            $this->shortOptions[$spec->short] = $spec;
        }
        $this->options[] = $spec;
        if (!$spec->long && !$spec->short) {
            throw new InvalidArgumentException('Neither long option name nor short name is not given.');
        }
    }
public function addOption ( Option $ spec ) { $ this -> data [ $ spec -> getId ( ) ] = $ spec ; if ( $ spec -> long ) { if ( isset ( $ this -> longOptions [ $ spec -> long ] ) ) { throw new OptionConflictException ( 'Option conflict: --' . $ spec -> long . ' is already defined.' ) ; } $ this -> longOptions [ $ spec -> long ] = $ spec ; } if ( $ spec -> short ) { if ( isset ( $ this -> shortOptions [ $ spec -> short ] ) ) { throw new OptionConflictException ( 'Option conflict: -' . $ spec -> short . ' is already defined.' ) ; } $ this -> shortOptions [ $ spec -> short ] = $ spec ; } $ this -> options [ ] = $ spec ; if ( ! $ spec -> long && ! $ spec -> short ) { throw new InvalidArgumentException ( 'Neither long option name nor short name is not given.' ) ; } }
Add option object.

@param Option $spec the option object.

@throws InvalidArgumentException
@throws OptionConflictException
Add option object .