public function getCommandAsString()
 {
     return BuildEscapedCommandLine::fromArray($this->getCommand());
 }
 /**
  * @covers ::from
  * @covers ::fromArray
  * @dataProvider provideCommands
  */
 public function testCanCallStatically($data, $expectedResult)
 {
     // ----------------------------------------------------------------
     // setup your test
     // ----------------------------------------------------------------
     // perform the change
     $actualResult = BuildEscapedCommandLine::from($data);
     // ----------------------------------------------------------------
     // test the results
     $this->assertEquals($expectedResult, $actualResult);
 }
 /**
  * start the command
  *
  * @param  array|Traversable $command
  *         the command to execute
  * @param  string|null $cwd
  *         the folder to run the command inside
  * @return array
  *         0 - the process handle
  *         1 - the array of pipes to interact with the process
  */
 private static function startProcess($command, $cwd = null)
 {
     // create the command to execute
     $cmdToExecute = BuildEscapedCommandLine::from($command);
     // how we will talk to the process
     $pipes = [];
     // start the process
     $process = proc_open($cmdToExecute, self::buildPipesSpec(), $pipes, $cwd);
     if (!$process) {
         // fork failed?
         throw new E5xx_ProcessFailedToStart($command);
     }
     // we do not want to block whilst reading from the child process
     stream_set_blocking($pipes[1], 0);
     stream_set_blocking($pipes[2], 0);
     // all done
     return [$process, $pipes];
 }
 /**
  * exception thrown when we have failed to start a command
  *
  * @param array|Traversable $command
  *        the command that failed to start
  */
 public function __construct($command)
 {
     $msg = "Command " . BuildEscapedCommandLine::from($command) . ' failed to start';
     parent::__construct(500, $msg, ['command' => $command]);
 }