Extract a Process class that wraps Symfony's
This commit is contained in:
parent
3ed3ee85b8
commit
cf89ca76a0
2 changed files with 34 additions and 21 deletions
26
src/Process/Process.php
Normal file
26
src/Process/Process.php
Normal file
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Process;
|
||||
|
||||
use Symfony\Component\Process\Process as SymfonyProcess;
|
||||
|
||||
/**
|
||||
* Create a new Process instance with some extra options.
|
||||
*
|
||||
* @param non-empty-array<int, non-empty-string> $command
|
||||
* @param string $workingDir
|
||||
* @param ?string $extraArgs
|
||||
*/
|
||||
final class Process
|
||||
{
|
||||
public static function create(array $command, string $workingDir, ?string $extraArgs = null): SymfonyProcess
|
||||
{
|
||||
$process = new SymfonyProcess(command: array_filter([...$command, $extraArgs]));
|
||||
$process->setTty(true);
|
||||
$process->setWorkingDirectory($workingDir);
|
||||
|
||||
return $process;
|
||||
}
|
||||
}
|
Reference in a new issue