@@ -62,28 +62,6 @@ private function sanityCheck()
62
62
}
63
63
}
64
64
65
- public function upload (string $ localPath , string $ remotePath ): bool
66
- {
67
- if (!is_resource ($ this ->resource )) {
68
- throw new InvalidArgumentException ('The session resource is invalid. ' );
69
- }
70
-
71
- if (!file_exists ($ localPath )) {
72
- throw new InvalidArgumentException ('The localPath is invalid. ' );
73
- }
74
-
75
- return ssh2_scp_send ($ this ->resource , $ localPath , $ remotePath );
76
- }
77
-
78
- public function download (string $ remotePath , string $ localPath ): bool
79
- {
80
- if (!is_resource ($ this ->resource )) {
81
- throw new InvalidArgumentException ('The session resource is invalid. ' );
82
- }
83
-
84
- return ssh2_scp_recv ($ this ->resource , $ remotePath , $ localPath );
85
- }
86
-
87
65
public function connect (): self
88
66
{
89
67
$ this ->sanityCheck ();
@@ -109,7 +87,7 @@ public function connect(): self
109
87
return $ this ;
110
88
}
111
89
112
- public function disconnect ()
90
+ public function disconnect (): void
113
91
{
114
92
if (!$ this ->connected ) {
115
93
throw new RuntimeException ('Unable to disconnect. Not yet connected. ' );
@@ -118,12 +96,34 @@ public function disconnect()
118
96
ssh2_disconnect ($ this ->resource );
119
97
}
120
98
121
- public function run (string $ command )
99
+ public function run (string $ command ): SSHCommand
122
100
{
123
101
if (!$ this ->connected ) {
124
102
throw new RuntimeException ('Unable to run commands when not connected. ' );
125
103
}
126
104
127
105
return new SSHCommand ($ this ->resource , $ command );
128
106
}
107
+
108
+ public function upload (string $ localPath , string $ remotePath ): bool
109
+ {
110
+ if (!$ this ->connected ) {
111
+ throw new RuntimeException ('Unable to upload file when not connected. ' );
112
+ }
113
+
114
+ if (!file_exists ($ localPath )) {
115
+ throw new InvalidArgumentException ('The local file does not exist. ' );
116
+ }
117
+
118
+ return ssh2_scp_send ($ this ->resource , $ localPath , $ remotePath );
119
+ }
120
+
121
+ public function download (string $ remotePath , string $ localPath ): bool
122
+ {
123
+ if (!$ this ->connected ) {
124
+ throw new RuntimeException ('Unable to download file when not connected. ' );
125
+ }
126
+
127
+ return ssh2_scp_recv ($ this ->resource , $ remotePath , $ localPath );
128
+ }
129
129
}
0 commit comments