public function parseArguments(array $args)
    {
        $this->action = null;
        $this->arguments = array();
        $parsed = array();
        $argument = reset($args);
        while ($argument) {
            if (strpos($argument, '=') > 0) {
                $arg = explode('=', $argument);
                $argKey = ltrim($arg[0], '-');
                $argValue = trim($arg[1], '"');
                $parsed[$argKey] = $argValue;
            } else {
                $parsed[ltrim($argument, '-')] = true;
            }
            $argument = next($args);
        }
        if (!isset($parsed['action']) || empty($parsed['action'])) {
            if (isset($parsed['version']) ||  isset($parsed['V'])) {
                $this->action = 'Version';
                $this->arguments = $parsed;
                return $this->arguments;
            }
            if (isset($parsed['help']) || isset($parsed['h'])) {
                $this->action = 'Help';
                $this->arguments = $parsed;
                return $this->arguments;
            }
            throw new RequestException($this, "No valid action argument specified.");
        }
        $this->action = $parsed['action'];
        unset($parsed['action']);
        $this->arguments = $parsed;
        return $this->arguments;
    }
public function parseArguments(array $args)
    {
        $this->action = null;
        $this->arguments = array();
        $parsed = array();
        $argument = reset($args);
        while ($argument) {
            if (strpos($argument, '=') > 0) {
                $arg = explode('=', $argument);
                $argKey = ltrim($arg[0], '-');
                $argValue = trim($arg[1], '"');
                $parsed[$argKey] = $argValue;
            } else {
                $parsed[ltrim($argument, '-')] = true;
            }
            $argument = next($args);
        }
        if (!isset($parsed['action']) || empty($parsed['action'])) {
            if (isset($parsed['version']) ||  isset($parsed['V'])) {
                $this->action = 'Version';
                $this->arguments = $parsed;
                return $this->arguments;
            }
            if (isset($parsed['help']) || isset($parsed['h'])) {
                $this->action = 'Help';
                $this->arguments = $parsed;
                return $this->arguments;
            }
            throw new RequestException($this, "No valid action argument specified.");
        }
        $this->action = $parsed['action'];
        unset($parsed['action']);
        $this->arguments = $parsed;
        return $this->arguments;
    }
public function parseArguments ( array $ args ) { $ this -> action = null ; $ this -> arguments = array ( ) ; $ parsed = array ( ) ; $ argument = reset ( $ args ) ; while ( $ argument ) { if ( strpos ( $ argument , '=' ) > 0 ) { $ arg = explode ( '=' , $ argument ) ; $ argKey = ltrim ( $ arg [ 0 ] , '-' ) ; $ argValue = trim ( $ arg [ 1 ] , '"' ) ; $ parsed [ $ argKey ] = $ argValue ; } else { $ parsed [ ltrim ( $ argument , '-' ) ] = true ; } $ argument = next ( $ args ) ; } if ( ! isset ( $ parsed [ 'action' ] ) || empty ( $ parsed [ 'action' ] ) ) { if ( isset ( $ parsed [ 'version' ] ) || isset ( $ parsed [ 'V' ] ) ) { $ this -> action = 'Version' ; $ this -> arguments = $ parsed ; return $ this -> arguments ; } if ( isset ( $ parsed [ 'help' ] ) || isset ( $ parsed [ 'h' ] ) ) { $ this -> action = 'Help' ; $ this -> arguments = $ parsed ; return $ this -> arguments ; } throw new RequestException ( $ this , "No valid action argument specified." ) ; } $ this -> action = $ parsed [ 'action' ] ; unset ( $ parsed [ 'action' ] ) ; $ this -> arguments = $ parsed ; return $ this -> arguments ; }
Parse the CLI request arguments into a normalized format.

@param array $args An array of CLI arguments to parse.

@return array The normalized array of parsed arguments.
@throws RequestException If no valid action argument is specified.
Parse the CLI request arguments into a normalized format .