コード例 #1
0
ファイル: Passthru.php プロジェクト: treffynnon/cmdwrap
 /**
  * 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 = '';
 }
コード例 #2
0
ファイル: Exec.php プロジェクト: treffynnon/cmdwrap
 /**
  * @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;
 }
コード例 #3
0
ファイル: System.php プロジェクト: treffynnon/cmdwrap
 /**
  * @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;
 }
コード例 #4
0
ファイル: SymfonyProcess.php プロジェクト: treffynnon/cmdwrap
 public function getEnvVarArray(RunnableInterface $command)
 {
     return $command->getCommandAssembler()->getCommandLine(function ($item) {
         return $item instanceof CL\EnvVarInterface;
     })->get();
 }