for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php declare(strict_types=1);
namespace Shopware\Psh\ScriptRuntime;
/**
* Again, a statefull builder to ease the parsing
*/
class CommandBuilder
{
* @var ProcessCommand[]
private $allCommands = [];
* @var bool
private $ignoreError;
private $tty;
private $template;
private $deferred;
public function __construct()
$this->reset();
}
private function reset()
$this->ignoreError = false;
$this->tty = false;
$this->template = false;
$this->deferred = false;
* @param string $shellCommand
* @param int $startLine
* @return CommandBuilder
public function addProcessCommand(string $shellCommand, int $startLine): CommandBuilder
$this->allCommands[] = new ProcessCommand(
$shellCommand,
$startLine,
$this->ignoreError,
$this->tty,
$this->deferred
);
return $this;
* @param string $source
* @param string $destination
* @param int $lineNumber
* @return $this
public function addTemplateCommand(string $source, string $destination, int $lineNumber): CommandBuilder
$this->allCommands[] = new TemplateCommand(
$source,
$destination,
$lineNumber
public function addWaitCommand(int $lineNumber): CommandBuilder
$this->allCommands[] = new WaitCommand($lineNumber);
* @param bool $set
public function setIgnoreError(bool $set = true): CommandBuilder
$this->ignoreError = $set;
public function setTty(bool $set = true): CommandBuilder
$this->tty = $set;
public function setDeferredExecution(bool $set = true): CommandBuilder
$this->deferred = $set;
* @param array $commands
public function replaceCommands(array $commands): CommandBuilder
$this->allCommands = $commands;
* @return ProcessCommand[]
public function getAll(): array
$allCommands = $this->allCommands;
$this->allCommands = [];
return $allCommands;