File tree Expand file tree Collapse file tree 2 files changed +5
-28
lines changed Expand file tree Collapse file tree 2 files changed +5
-28
lines changed Original file line number Diff line number Diff line change @@ -96,30 +96,12 @@ public function disconnect()
9696 ssh2_disconnect ($ this ->resource );
9797 }
9898
99- public function run ($ commands )
99+ public function run (string $ command )
100100 {
101- if (is_string ($ commands )) {
102- $ commands = [$ commands ];
103- }
104-
105- if (!is_array ($ commands )) {
106- throw new InvalidArgumentException ('Command(s) passed should be a string or an array of string. ' );
107- }
108-
109101 if (!$ this ->connected ) {
110102 throw new RuntimeException ('Unable to run commands when not connected. ' );
111103 }
112104
113- $ results = [];
114-
115- foreach ($ commands as $ command ) {
116- $ results [] = new SSHCommand ($ this ->resource , $ command );
117- }
118-
119- if (count ($ results ) === 1 ) {
120- return $ results [0 ];
121- }
122-
123- return $ results ;
105+ return new SSHCommand ($ this ->resource , $ command );
124106 }
125107}
Original file line number Diff line number Diff line change 1111 ->withPassword ('password ' )
1212 ->connect ();
1313
14- $ outputs = $ connection ->run ([
15- 'ls -lah ' ,
16- 'echo "Hello world!" ' ,
17- ]);
14+ $ output = $ connection ->run ('ls -lah ' );
1815
19- foreach ($ outputs as $ output ) {
20- var_dump ($ output ->getOutput ());
21- var_dump ($ output ->getError ());
22- }
16+ var_dump ($ output ->getOutput ());
17+ var_dump ($ output ->getError ());
You can’t perform that action at this time.
0 commit comments