classes/Shell.php
protected static function _compileCommand($command,array $params){
        $s = $w = [];
        foreach ($params as $p) {
            if ($p instanceof static) {
              $s[] = '$('.$p->getShellCommand().')';
            } else if (is_array($p)) foreach ($p as $key => $value) {
                if(is_numeric($key)){
                  $w[] = '--'.$value;
                } else {
                  if(is_bool($value)){
                     if($value) $w[] = '--'.$key;
                  } else {
                    $w[] = '--'.$key.'='.escapeshellarg($value);
                  }
                }
            } else {
              $s[] = $p;
            }
        }
        return trim(
            '/usr/bin/env '.$command.' '.implode(' ',array_merge($w,$s))
        );
    }
protected static function _compileCommand($command,array $params){
        $s = $w = [];
        foreach ($params as $p) {
            if ($p instanceof static) {
              $s[] = '$('.$p->getShellCommand().')';
            } else if (is_array($p)) foreach ($p as $key => $value) {
                if(is_numeric($key)){
                  $w[] = '--'.$value;
                } else {
                  if(is_bool($value)){
                     if($value) $w[] = '--'.$key;
                  } else {
                    $w[] = '--'.$key.'='.escapeshellarg($value);
                  }
                }
            } else {
              $s[] = $p;
            }
        }
        return trim(
            '/usr/bin/env '.$command.' '.implode(' ',array_merge($w,$s))
        );
    }
protected static function _compileCommand ( $ command , array $ params ) { $ s = $ w = [ ] ; foreach ( $ params as $ p ) { if ( $ p instanceof static ) { $ s [ ] = '$(' . $ p -> getShellCommand ( ) . ')' ; } else if ( is_array ( $ p ) ) foreach ( $ p as $ key => $ value ) { if ( is_numeric ( $ key ) ) { $ w [ ] = '--' . $ value ; } else { if ( is_bool ( $ value ) ) { if ( $ value ) $ w [ ] = '--' . $ key ; } else { $ w [ ] = '--' . $ key . '=' . escapeshellarg ( $ value ) ; } } } else { $ s [ ] = $ p ; } } return trim ( '/usr/bin/env ' . $ command . ' ' . implode ( ' ' , array_merge ( $ w , $ s ) ) ) ; }
Compile a shell command
@param string $command
@param array $params
@return string
Compile a shell command