Skip to content
  • Sponsor
  • Notifications You must be signed in to change notification settings
  • Fork 22

Commit f7fd6ec

Browse files
committedJul 30, 2019
Remove multi-command execution
1 parent f54a7f5 commit f7fd6ec

File tree

2 files changed

+5
-28
lines changed

2 files changed

+5
-28
lines changed
 

Diff for: ‎src/SSHConnection.php

+2-20
Original file line numberDiff line numberDiff 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
}

Diff for: ‎src/test.php

+3-8
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,7 @@
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());

0 commit comments

Comments
 (0)