11<?php
22
3- namespace SystemCtl \Command ;
3+ namespace icanhazstring \ SystemCtl \Command ;
44
5+ use Symfony \Component \Process \Process ;
56use Symfony \Component \Process \ProcessBuilder ;
67
78/**
89 * Class SymfonyCommandDispatcher
910 *
10- * @package SystemCtl\Command
11+ * @package icanhazstring\ SystemCtl\Command
1112 * @author icanhazstring <[email protected] > 1213 */
1314class SymfonyCommandDispatcher implements CommandDispatcherInterface
1415{
16+ /** @var string */
1517 private $ binary ;
16- private $ timetout ;
18+ /** @var int */
19+ private $ timeout ;
1720
1821 /**
1922 * @inheritdoc
@@ -30,7 +33,7 @@ public function setBinary(string $binary): CommandDispatcherInterface
3033 */
3134 public function setTimeout (int $ timeout ): CommandDispatcherInterface
3235 {
33- $ this ->timetout = $ timeout ;
36+ $ this ->timeout = $ timeout ;
3437
3538 return $ this ;
3639 }
@@ -40,12 +43,10 @@ public function setTimeout(int $timeout): CommandDispatcherInterface
4043 */
4144 public function dispatch (...$ commands ): CommandInterface
4245 {
43- $ processBuilder = new ProcessBuilder ();
44- $ processBuilder ->setPrefix ($ this ->binary );
45- $ processBuilder ->setTimeout ($ this ->timetout );
46- $ processBuilder ->setArguments ($ commands );
46+ $ process = new Process (array_merge ([$ this ->binary ], $ commands ));
47+ $ process ->setTimeout ($ this ->timeout );
4748
48- $ process = new SymfonyCommand ($ processBuilder -> getProcess () );
49+ $ process = new SymfonyCommand ($ process );
4950
5051 return $ process ->run ();
5152 }
0 commit comments