Argument.php
public function parse(Array $arguments)
    {
        $this->arguments = array();
        $arguments = new ArgumentIterator($arguments);

        foreach ($arguments as $current) {

            $arguments->next();
            $next = ($arguments->valid() ? $arguments->current() : '');
            $arguments->prev();

            $arg1 = substr($current, 0, 1);
            $arg2 = substr($current, 0, 2);

            if ('--' == $arg2) {

                // ~ Case '--test'
                $arg = array();
                $match = preg_match('`--([0-9a-z_-]+)="?(.+)"?`', $current, $arg);

                if ($match > 0) {
                    $this->arguments[$arg[1]] = $arg[2];
                } else
                    if (! empty($next) && '-' !== substr($next, 0, 1)) {
                        $this->arguments[substr($current, 2)] = $next;
                    } else {
                        $this->arguments[substr($current, 2)] = true;
                    }
            } elseif ('-' == $arg1) {

                // ~ case -t
                $arg = substr($current, 1);
                $len = strlen($arg);

                if (1 == $len && ! empty($next) && '-' != substr($next, 0, 1)) {
                    $this->arguments[$arg] = $next;
                } else {
                    for ($letter = 0; $letter < $len; $letter ++) {
                        $this->arguments[$arg[$letter]] = true;
                    }
                }
            }
        }

        return $this;
    }
public function parse(Array $arguments)
    {
        $this->arguments = array();
        $arguments = new ArgumentIterator($arguments);

        foreach ($arguments as $current) {

            $arguments->next();
            $next = ($arguments->valid() ? $arguments->current() : '');
            $arguments->prev();

            $arg1 = substr($current, 0, 1);
            $arg2 = substr($current, 0, 2);

            if ('--' == $arg2) {

                // ~ Case '--test'
                $arg = array();
                $match = preg_match('`--([0-9a-z_-]+)="?(.+)"?`', $current, $arg);

                if ($match > 0) {
                    $this->arguments[$arg[1]] = $arg[2];
                } else
                    if (! empty($next) && '-' !== substr($next, 0, 1)) {
                        $this->arguments[substr($current, 2)] = $next;
                    } else {
                        $this->arguments[substr($current, 2)] = true;
                    }
            } elseif ('-' == $arg1) {

                // ~ case -t
                $arg = substr($current, 1);
                $len = strlen($arg);

                if (1 == $len && ! empty($next) && '-' != substr($next, 0, 1)) {
                    $this->arguments[$arg] = $next;
                } else {
                    for ($letter = 0; $letter < $len; $letter ++) {
                        $this->arguments[$arg[$letter]] = true;
                    }
                }
            }
        }

        return $this;
    }
public function parse ( Array $ arguments ) { $ this -> arguments = array ( ) ; $ arguments = new ArgumentIterator ( $ arguments ) ; foreach ( $ arguments as $ current ) { $ arguments -> next ( ) ; $ next = ( $ arguments -> valid ( ) ? $ arguments -> current ( ) : '' ) ; $ arguments -> prev ( ) ; $ arg1 = substr ( $ current , 0 , 1 ) ; $ arg2 = substr ( $ current , 0 , 2 ) ; if ( '--' == $ arg2 ) { // ~ Case '--test' $ arg = array ( ) ; $ match = preg_match ( '`--([0-9a-z_-]+)="?(.+)"?`' , $ current , $ arg ) ; if ( $ match > 0 ) { $ this -> arguments [ $ arg [ 1 ] ] = $ arg [ 2 ] ; } else if ( ! empty ( $ next ) && '-' !== substr ( $ next , 0 , 1 ) ) { $ this -> arguments [ substr ( $ current , 2 ) ] = $ next ; } else { $ this -> arguments [ substr ( $ current , 2 ) ] = true ; } } elseif ( '-' == $ arg1 ) { // ~ case -t $ arg = substr ( $ current , 1 ) ; $ len = strlen ( $ arg ) ; if ( 1 == $ len && ! empty ( $ next ) && '-' != substr ( $ next , 0 , 1 ) ) { $ this -> arguments [ $ arg ] = $ next ; } else { for ( $ letter = 0 ; $ letter < $ len ; $ letter ++ ) { $ this -> arguments [ $ arg [ $ letter ] ] = true ; } } } } return $ this ; }
Parse argument from command lines.

@param array $arguments Parameter for this function is $argv global variable.
@return Argument
Parse argument from command lines .