src/Phossa/Console/GetOpt.php
/**
     * Parse command line arguments
     *
     * @param  array $arguments command line arguments
     * @return array
     * @throws Exception\InvalidArgumentException
     *         if command line argument has error
     * @access protected
     */
Parse command line arguments
@param  array $arguments command line arguments
@return array
@throws Exception\InvalidArgumentException
if command line argument has error
@access protected
Parse command line arguments @param array $arguments command line arguments @return array @throws Exception \ InvalidArgumentException if command line argument has error @access protected
protected function parseArguments(
        array $arguments
    ) {
        $nonopts  = [];
        $goodopts = [];
        while(list($i, $arg) = each($arguments)) {
            if ($arg == '--') {
                $nonopts = array_merge(
                    $nonopts,
                    array_slice($arguments, $i + 1)
                );
                break;
            }
                        if ($arg == '-') {
                $nonopts[] = $arg;
                continue;
            }
            if ($arg[0] == '-') {
                if (!$this->parseOne($arg, $arguments)) break;
            } else {
                $nonopts[] = $arg;
            }
        }
        if (empty($this->error)) {
            foreach($this->options as $opt) {
                $val = $opt->getValue();
                if (!is_null($val)) {
                    $goodopts[$opt->getName()] = $val;
                } else if ($opt->isRequired()) {
                    throw new Exception\InvalidArgumentException(
                        Message::get(
                            Message::GETOPT_OPTION_MISSING, $opt->getName()
                        ),
                        Message::GETOPT_OPTION_MISSING
                    );
                }
            }
        } else {
            throw new Exception\InvalidArgumentException(
                Message::get(
                    Message::GETOPT_ARGUMENT_ERROR,
                    $this->error
                ),
                Message::GETOPT_ARGUMENT_ERROR
            );
        }
        return array($goodopts, $nonopts);
    }
protected function parseArguments ( array $ arguments ) { $ nonopts = [ ] ; $ goodopts = [ ] ; while ( list ( $ i , $ arg ) = each ( $ arguments ) ) { if ( $ arg == '--' ) { $ nonopts = array_merge ( $ nonopts , array_slice ( $ arguments , $ i + 1 ) ) ; break ; } if ( $ arg == '-' ) { $ nonopts [ ] = $ arg ; continue ; } if ( $ arg [ 0 ] == '-' ) { if ( ! $ this -> parseOne ( $ arg , $ arguments ) ) break ; } else { $ nonopts [ ] = $ arg ; } } if ( empty ( $ this -> error ) ) { foreach ( $ this -> options as $ opt ) { $ val = $ opt -> getValue ( ) ; if ( ! is_null ( $ val ) ) { $ goodopts [ $ opt -> getName ( ) ] = $ val ; } else if ( $ opt -> isRequired ( ) ) { throw new Exception \ InvalidArgumentException ( Message :: get ( Message :: GETOPT_OPTION_MISSING , $ opt -> getName ( ) ) , Message :: GETOPT_OPTION_MISSING ) ; } } } else { throw new Exception \ InvalidArgumentException ( Message :: get ( Message :: GETOPT_ARGUMENT_ERROR , $ this -> error ) , Message :: GETOPT_ARGUMENT_ERROR ) ; } return array ( $ goodopts , $ nonopts ) ; }
Parse command line arguments
 @param  array $arguments command line arguments
 @return array
 @throws Exception\InvalidArgumentException
         if command line argument has error
 @access protected
Parse command line arguments @param array $arguments command line arguments @return array @throws Exception \ InvalidArgumentException if command line argument has error @access protected
/*# : array */ // stop processing options // from stdin ?
 // options // clean up // result