public function parse($panic = false) {
        list($shorts, $longs) = $this->getOptionsSearchStrings();
        $options = getopt($shorts, $longs);
        $Exception = null;
        foreach ($this->parameters as $Option) {
            /** @var $Option Option */
            $short = $Option->getShort();
            $long = $Option->getLong();
            switch (true) {
                case isset($options[$short]) && isset($options[$long]):
                    throw new DuplicateOptionException();
                case isset($options[$short]):
                    $this->setOptionValue($Option, $this->getPreparedValue($options[$short]));
                    break;
                case isset($options[$long]):
                    $this->setOptionValue($Option, $this->getPreparedValue($options[$long]));
                    break;
                case $Option->isRequired():
                    $Exception = new RequiredOptionException($long);
            }
        }

        if ($panic && !is_null($Exception)) {
            throw $Exception;
        }
    }
public function parse($panic = false) {
        list($shorts, $longs) = $this->getOptionsSearchStrings();
        $options = getopt($shorts, $longs);
        $Exception = null;
        foreach ($this->parameters as $Option) {
            /** @var $Option Option */
            $short = $Option->getShort();
            $long = $Option->getLong();
            switch (true) {
                case isset($options[$short]) && isset($options[$long]):
                    throw new DuplicateOptionException();
                case isset($options[$short]):
                    $this->setOptionValue($Option, $this->getPreparedValue($options[$short]));
                    break;
                case isset($options[$long]):
                    $this->setOptionValue($Option, $this->getPreparedValue($options[$long]));
                    break;
                case $Option->isRequired():
                    $Exception = new RequiredOptionException($long);
            }
        }

        if ($panic && !is_null($Exception)) {
            throw $Exception;
        }
    }
public function parse ( $ panic = false ) { list ( $ shorts , $ longs ) = $ this -> getOptionsSearchStrings ( ) ; $ options = getopt ( $ shorts , $ longs ) ; $ Exception = null ; foreach ( $ this -> parameters as $ Option ) { /** @var $Option Option */ $ short = $ Option -> getShort ( ) ; $ long = $ Option -> getLong ( ) ; switch ( true ) { case isset ( $ options [ $ short ] ) && isset ( $ options [ $ long ] ) : throw new DuplicateOptionException ( ) ; case isset ( $ options [ $ short ] ) : $ this -> setOptionValue ( $ Option , $ this -> getPreparedValue ( $ options [ $ short ] ) ) ; break ; case isset ( $ options [ $ long ] ) : $ this -> setOptionValue ( $ Option , $ this -> getPreparedValue ( $ options [ $ long ] ) ) ; break ; case $ Option -> isRequired ( ) : $ Exception = new RequiredOptionException ( $ long ) ; } } if ( $ panic && ! is_null ( $ Exception ) ) { throw $ Exception ; } }
POSIX parse command line method
@param bool $panic throw exception about required option absence
@throws DuplicateOptionException when option value duplicated
@throws RequiredOptionException when required options is not set
POSIX parse command line method