private function buildCommand($cmd, $args = array()) {
    while(list($name, $data) = each($args)) {
    $safeData = false;
      $filterType = mb_substr($name, 0, 1);
      switch($filterType) {
        case '%':
          $safeData = escapeshellarg($data);
          break;
        case '!':
          $safeData = escapeshellcmd($data);
          break;
        default:
          throw new \phpSec\Exception\InvalidArgumentException('Unknown variable type');
          break;
      }
      if($safeData !== false) {
        $cmd = str_replace($name, $safeData, $cmd);
      }
    }
    return $cmd;
  }
private function buildCommand($cmd, $args = array()) {
    while(list($name, $data) = each($args)) {
    $safeData = false;
      $filterType = mb_substr($name, 0, 1);
      switch($filterType) {
        case '%':
          $safeData = escapeshellarg($data);
          break;
        case '!':
          $safeData = escapeshellcmd($data);
          break;
        default:
          throw new \phpSec\Exception\InvalidArgumentException('Unknown variable type');
          break;
      }
      if($safeData !== false) {
        $cmd = str_replace($name, $safeData, $cmd);
      }
    }
    return $cmd;
  }
private function buildCommand ( $ cmd , $ args = array ( ) ) { while ( list ( $ name , $ data ) = each ( $ args ) ) { $ safeData = false ; $ filterType = mb_substr ( $ name , 0 , 1 ) ; switch ( $ filterType ) { case '%' : $ safeData = escapeshellarg ( $ data ) ; break ; case '!' : $ safeData = escapeshellcmd ( $ data ) ; break ; default : throw new \ phpSec \ Exception \ InvalidArgumentException ( 'Unknown variable type' ) ; break ; } if ( $ safeData !== false ) { $ cmd = str_replace ( $ name , $ safeData , $ cmd ) ; } } return $ cmd ; }
Builds a command that is safe to execute.

@param string $cmd
Base command (with placeholders) to execute.

@param array $args
An associative array containing data to filter.

@return string
Returns a command that is safe to execute.
Builds a command that is safe to execute .