/** * Passes through result of the command so no output is set * @link http://php.net/passthru * @param RunnableInterface $command */ public function run(RunnableInterface $command, callable $func = null) { if ($func) { throw new \Exception('You cannot process passthru with a callable. Use another Runner instead.'); } $this->lastCommand = (string) $command->getCommandAssembler(); passthru($this->lastCommand, $this->status); $this->output = ''; }
/** * @link http://php.net/manual/en/function.exec.php * @param RunnableInterface $command * @return string */ public function run(RunnableInterface $command, callable $func = null) { $this->lastCommand = (string) $command->getCommandAssembler(); $return = exec($this->lastCommand, $this->output, $this->status); if ($func) { $t = ''; foreach ($this->output as $line) { $t .= call_user_func($func, $line); } $this->output = $t; } return $return; }
/** * @link http://php.net/system * @param RunnableInterface $command * @return string */ public function run(RunnableInterface $command, callable $func = null) { $this->lastCommand = (string) $command->getCommandAssembler(); $this->output = system($this->lastCommand, $this->status); if ($func) { $t = ''; $x = preg_split("/\n/", $this->output); foreach ($x as $line) { $t .= call_user_func($func, $line); } $this->output = $t; } return $this->output; }
public function getEnvVarArray(RunnableInterface $command) { return $command->getCommandAssembler()->getCommandLine(function ($item) { return $item instanceof CL\EnvVarInterface; })->get(); }