public function map($definition)
    {
        $fixed = preg_replace('/\s+/', ' ', $definition);
        if (empty($fixed)) {
            return;
        }
        
        $names = explode(' ', $fixed);
        $newArgs = [];
        foreach ($this->args as $key => $value) {
            if (!is_int($key) && in_array($key, $names)) {
                throw new \Exception("Duplicate key {$key}");
            }

            if (is_int($key) && isset($names[$key])) {
                //Map command
                $newArgs[$names[$key]] = $value;
            } else {
                //Ignore options
                $newArgs[$key] = $value;
            }
        }
        $this->args = $newArgs;
    }
public function map($definition)
    {
        $fixed = preg_replace('/\s+/', ' ', $definition);
        if (empty($fixed)) {
            return;
        }
        
        $names = explode(' ', $fixed);
        $newArgs = [];
        foreach ($this->args as $key => $value) {
            if (!is_int($key) && in_array($key, $names)) {
                throw new \Exception("Duplicate key {$key}");
            }

            if (is_int($key) && isset($names[$key])) {
                //Map command
                $newArgs[$names[$key]] = $value;
            } else {
                //Ignore options
                $newArgs[$key] = $value;
            }
        }
        $this->args = $newArgs;
    }
public function map ( $ definition ) { $ fixed = preg_replace ( '/\s+/' , ' ' , $ definition ) ; if ( empty ( $ fixed ) ) { return ; } $ names = explode ( ' ' , $ fixed ) ; $ newArgs = [ ] ; foreach ( $ this -> args as $ key => $ value ) { if ( ! is_int ( $ key ) && in_array ( $ key , $ names ) ) { throw new \ Exception ( "Duplicate key {$key}" ) ; } if ( is_int ( $ key ) && isset ( $ names [ $ key ] ) ) { //Map command $ newArgs [ $ names [ $ key ] ] = $ value ; } else { //Ignore options $ newArgs [ $ key ] = $ value ; } } $ this -> args = $ newArgs ; }
Map command line arguments to keys
@param type $definition
Map command line arguments to keys