@@ -19,7 +19,7 @@ final class ShellBuilder implements ShellInterface, \JsonSerializable
1919{
2020 use ShellConditional;
2121
22- /** @var array<ShellInterface> */
22+ /** @var array<ShellInterface|string > */
2323 private $ commandList = [];
2424 /** @var int */
2525 private $ groupType ;
@@ -100,14 +100,28 @@ public function removeVariable(string $variable): self
100100 return $ this ;
101101 }
102102
103+ /**
104+ * @param string|ShellInterface ...$commands
105+ * @return $this
106+ * @throws ShellBuilderException
107+ */
108+ public function add (...$ commands ): self
109+ {
110+ foreach ($ commands as $ command ) {
111+ $ this ->addSingle ($ command );
112+ }
113+ return $ this ;
114+ }
115+
103116 /**
104117 * @param string|ShellInterface $command
118+ * @param bool $raw
105119 * @return $this
106120 * @throws ShellBuilderException
107121 */
108- public function add ($ command ): self
122+ public function addSingle ($ command, bool $ raw = false ): self
109123 {
110- $ command = $ this ->parseCommand ($ command , true );
124+ $ command = $ raw ? $ command : $ this ->parseCommand ($ command , true );
111125 if (empty ($ this ->commandList )) {
112126 $ this ->commandList [] = $ command ;
113127 return $ this ;
@@ -338,7 +352,7 @@ public function __toArray(): array
338352 {
339353 $ commands = [];
340354 foreach ($ this ->commandList as $ item ) {
341- $ commands [] = $ item ->__toArray ();
355+ $ commands [] = is_string ( $ item ) ? $ item : $ item ->__toArray ();
342356 }
343357 return $ commands ;
344358 }
0 commit comments