diff --git a/config/remote.php b/config/remote.php
index 0d9ceeb..705572d 100644
--- a/config/remote.php
+++ b/config/remote.php
@@ -51,7 +51,7 @@
*/
'groups' => [
- 'web' => [ 'production' ],
+ 'web' => ['production'],
],
];
diff --git a/src/Connection.php b/src/Connection.php
index b2cdec0..2ad3425 100755
--- a/src/Connection.php
+++ b/src/Connection.php
@@ -9,7 +9,6 @@
class Connection implements ConnectionInterface
{
-
/**
* The SSH gateway implementation.
*
@@ -43,7 +42,7 @@ class Connection implements ConnectionInterface
*
* @var array
*/
- protected $tasks = [ ];
+ protected $tasks = [];
/**
* The output implementation for the connection.
@@ -52,7 +51,6 @@ class Connection implements ConnectionInterface
*/
protected $output;
-
/**
* Create a new SSH connection instance.
*
@@ -65,13 +63,12 @@ class Connection implements ConnectionInterface
*/
public function __construct($name, $host, $username, array $auth, GatewayInterface $gateway = null, $timeout = 10)
{
- $this->name = $name;
- $this->host = $host;
+ $this->name = $name;
+ $this->host = $host;
$this->username = $username;
- $this->gateway = $gateway ?: new SecLibGateway($host, $auth, new Filesystem(), timeout);
+ $this->gateway = $gateway ?: new SecLibGateway($host, $auth, new Filesystem(), timeout);
}
-
/**
* Define a set of commands as a task.
*
@@ -85,7 +82,6 @@ public function define($task, $commands)
$this->tasks[$task] = $commands;
}
-
/**
* Run a task against the connection.
*
@@ -96,12 +92,11 @@ public function define($task, $commands)
*/
public function task($task, Closure $callback = null)
{
- if (isset( $this->tasks[$task] )) {
+ if (isset($this->tasks[$task])) {
$this->run($this->tasks[$task], $callback);
}
}
-
/**
* Run a set of commands against the connection.
*
@@ -133,7 +128,6 @@ public function run($commands, Closure $callback = null)
}
}
-
/**
* Get the gateway implementation.
*
@@ -143,14 +137,13 @@ public function run($commands, Closure $callback = null)
*/
public function getGateway()
{
- if ( ! $this->gateway->connected() && ! $this->gateway->connect($this->username)) {
+ if (!$this->gateway->connected() && !$this->gateway->connect($this->username)) {
throw new \RuntimeException('Unable to connect to remote server.');
}
return $this->gateway;
}
-
/**
* Get the display callback for the connection.
*
@@ -160,7 +153,7 @@ public function getGateway()
*/
protected function getCallback($callback)
{
- if ( ! is_null($callback)) {
+ if (!is_null($callback)) {
return $callback;
}
@@ -169,7 +162,6 @@ protected function getCallback($callback)
};
}
-
/**
* Display the given line using the default output.
*
@@ -179,14 +171,13 @@ protected function getCallback($callback)
*/
public function display($line)
{
- $server = $this->username . '@' . $this->host;
+ $server = $this->username.'@'.$this->host;
- $lead = '[' . $server . '] (' . $this->name . ')';
+ $lead = '['.$server.'] ('.$this->name.')';
- $this->getOutput()->writeln($lead . ' ' . $line);
+ $this->getOutput()->writeln($lead.' '.$line);
}
-
/**
* Get the output implementation for the connection.
*
@@ -201,7 +192,6 @@ public function getOutput()
return $this->output;
}
-
/**
* Set the output implementation.
*
@@ -214,7 +204,6 @@ public function setOutput(OutputInterface $output)
$this->output = $output;
}
-
/**
* Format the given command set.
*
@@ -227,7 +216,6 @@ protected function formatCommands($commands)
return is_array($commands) ? implode(' && ', $commands) : $commands;
}
-
/**
* Download the contents of a remote file.
*
@@ -241,7 +229,6 @@ public function get($remote, $local)
$this->getGateway()->get($remote, $local);
}
-
/**
* Get the contents of a remote file.
*
@@ -254,7 +241,6 @@ public function getString($remote)
return $this->getGateway()->getString($remote);
}
-
/**
* Upload a local file to the server.
*
@@ -268,7 +254,6 @@ public function put($local, $remote)
$this->getGateway()->put($local, $remote);
}
-
/**
* Upload a string to to the given file on the server.
*
@@ -282,7 +267,6 @@ public function putString($remote, $contents)
$this->getGateway()->putString($remote, $contents);
}
-
/**
* Check whether a given file exists on the server.
*
@@ -295,7 +279,6 @@ public function exists($remote)
return $this->getGateway()->exists($remote);
}
-
/**
* Rename a remote file.
*
@@ -309,7 +292,6 @@ public function rename($remote, $newRemote)
return $this->getGateway()->rename($remote, $newRemote);
}
-
/**
* Delete a remote file from the server.
*
@@ -322,7 +304,6 @@ public function delete($remote)
return $this->getGateway()->delete($remote);
}
-
/**
* Get the exit status of the last command.
*
diff --git a/src/ConnectionInterface.php b/src/ConnectionInterface.php
index 1bb963f..a15f39d 100755
--- a/src/ConnectionInterface.php
+++ b/src/ConnectionInterface.php
@@ -6,7 +6,6 @@
interface ConnectionInterface
{
-
/**
* Define a set of commands as a task.
*
@@ -17,7 +16,6 @@ interface ConnectionInterface
*/
public function define($task, $commands);
-
/**
* Run a task against the connection.
*
@@ -28,7 +26,6 @@ public function define($task, $commands);
*/
public function task($task, Closure $callback = null);
-
/**
* Run a set of commands against the connection.
*
@@ -39,7 +36,6 @@ public function task($task, Closure $callback = null);
*/
public function run($commands, Closure $callback = null);
-
/**
* Download the contents of a remote file.
*
@@ -50,7 +46,6 @@ public function run($commands, Closure $callback = null);
*/
public function get($remote, $local);
-
/**
* Get the contents of a remote file.
*
@@ -60,7 +55,6 @@ public function get($remote, $local);
*/
public function getString($remote);
-
/**
* Upload a local file to the server.
*
@@ -71,7 +65,6 @@ public function getString($remote);
*/
public function put($local, $remote);
-
/**
* Upload a string to the given file on the server.
*
@@ -82,7 +75,6 @@ public function put($local, $remote);
*/
public function putString($remote, $contents);
-
/**
* Check whether a given file exists on the server.
*
@@ -92,7 +84,6 @@ public function putString($remote, $contents);
*/
public function exists($remote);
-
/**
* Rename a remote file.
*
@@ -103,7 +94,6 @@ public function exists($remote);
*/
public function rename($remote, $newRemote);
-
/**
* Delete a remote file from the server.
*
diff --git a/src/GatewayInterface.php b/src/GatewayInterface.php
index 3ff68bc..3b537de 100755
--- a/src/GatewayInterface.php
+++ b/src/GatewayInterface.php
@@ -38,6 +38,7 @@ public function run($command);
* @return void
*/
public function get($remote, $local);
+
/**
* Get the contents of a remote file.
*
diff --git a/src/RemoteManager.php b/src/RemoteManager.php
index 0a3cf96..f6dfdae 100755
--- a/src/RemoteManager.php
+++ b/src/RemoteManager.php
@@ -8,7 +8,6 @@
class RemoteManager
{
-
/**
* The application instance.
*
@@ -16,7 +15,6 @@ class RemoteManager
*/
protected $app;
-
/**
* Create a new remote manager instance.
*
@@ -27,7 +25,6 @@ public function __construct(Application $app)
$this->app = $app;
}
-
/**
* Get a remote connection instance.
*
@@ -44,7 +41,6 @@ public function into($name)
}
}
-
/**
* Get a remote connection instance.
*
@@ -61,7 +57,6 @@ public function connection($name = null)
return $this->resolve($name ?: $this->getDefaultConnection());
}
-
/**
* Resolve a multiple connection instance.
*
@@ -71,10 +66,9 @@ public function connection($name = null)
*/
public function multiple(array $names)
{
- return new MultiConnection(array_map([ $this, 'resolve' ], $names));
+ return new MultiConnection(array_map([$this, 'resolve'], $names));
}
-
/**
* Resolve a remote connection instance.
*
@@ -87,7 +81,6 @@ public function resolve($name)
return $this->makeConnection($name, $this->getConfig($name));
}
-
/**
* Make a new connection instance.
*
@@ -107,7 +100,6 @@ protected function makeConnection($name, array $config)
return $connection;
}
-
/**
* Set the output implementation on the connection.
*
@@ -122,7 +114,6 @@ protected function setOutput(Connection $connection)
$connection->setOutput($output);
}
-
/**
* Format the appropriate authentication array payload.
*
@@ -134,20 +125,19 @@ protected function setOutput(Connection $connection)
*/
protected function getAuth(array $config)
{
- if (isset( $config['agent'] ) && $config['agent'] === true) {
- return [ 'agent' => true ];
- } elseif (isset( $config['key'] ) && trim($config['key']) != '') {
- return [ 'key' => $config['key'], 'keyphrase' => $config['keyphrase'] ];
- } elseif (isset( $config['keytext'] ) && trim($config['keytext']) != '') {
- return [ 'keytext' => $config['keytext'] ];
- } elseif (isset( $config['password'] )) {
- return [ 'password' => $config['password'] ];
+ if (isset($config['agent']) && $config['agent'] === true) {
+ return ['agent' => true];
+ } elseif (isset($config['key']) && trim($config['key']) != '') {
+ return ['key' => $config['key'], 'keyphrase' => $config['keyphrase']];
+ } elseif (isset($config['keytext']) && trim($config['keytext']) != '') {
+ return ['keytext' => $config['keytext']];
+ } elseif (isset($config['password'])) {
+ return ['password' => $config['password']];
}
throw new \InvalidArgumentException('Password / key is required.');
}
-
/**
* Get the configuration for a remote server.
*
@@ -159,16 +149,15 @@ protected function getAuth(array $config)
*/
protected function getConfig($name)
{
- $config = $this->app['config']['remote.connections.' . $name];
+ $config = $this->app['config']['remote.connections.'.$name];
- if ( ! is_null($config)) {
+ if (!is_null($config)) {
return $config;
}
throw new \InvalidArgumentException("Remote connection [$name] not defined.");
}
-
/**
* Get the default connection name.
*
@@ -179,7 +168,6 @@ public function getDefaultConnection()
return $this->app['config']['remote.default'];
}
-
/**
* Get a connection group instance by name.
*
@@ -189,10 +177,9 @@ public function getDefaultConnection()
*/
public function group($name)
{
- return $this->connection($this->app['config']['remote.groups.' . $name]);
+ return $this->connection($this->app['config']['remote.groups.'.$name]);
}
-
/**
* Set the default connection name.
*
@@ -205,7 +192,6 @@ public function setDefaultConnection($name)
$this->app['config']['remote.default'] = $name;
}
-
/**
* Dynamically pass methods to the default connection.
*
@@ -216,6 +202,6 @@ public function setDefaultConnection($name)
*/
public function __call($method, $parameters)
{
- return call_user_func_array([ $this->connection(), $method ], $parameters);
+ return call_user_func_array([$this->connection(), $method], $parameters);
}
}
diff --git a/src/SecLibGateway.php b/src/SecLibGateway.php
index 3324fe9..efd9a97 100755
--- a/src/SecLibGateway.php
+++ b/src/SecLibGateway.php
@@ -10,7 +10,6 @@
class SecLibGateway implements GatewayInterface
{
-
/**
* The host name of the server.
*
@@ -53,7 +52,6 @@ class SecLibGateway implements GatewayInterface
*/
protected $connection;
-
/**
* Create a new gateway implementation.
*
@@ -64,13 +62,12 @@ class SecLibGateway implements GatewayInterface
*/
public function __construct($host, array $auth, Filesystem $files, $timeout)
{
- $this->auth = $auth;
+ $this->auth = $auth;
$this->files = $files;
$this->setHostAndPort($host);
$this->setTimeout($timeout);
}
-
/**
* Set the host and port from a full host string.
*
@@ -80,16 +77,15 @@ public function __construct($host, array $auth, Filesystem $files, $timeout)
*/
protected function setHostAndPort($host)
{
- if ( ! str_contains($host, ':')) {
+ if (!str_contains($host, ':')) {
$this->host = $host;
} else {
- list( $this->host, $this->port ) = explode(':', $host);
+ list($this->host, $this->port) = explode(':', $host);
$this->port = (int) $this->port;
}
}
-
/**
* Connect to the SSH server.
*
@@ -102,13 +98,11 @@ public function connect($username)
return $this->getConnection()->login($username, $this->getAuthForLogin());
}
-
/**
* Get the underlying SFTP connection.
*
* @return \phpseclib\Net\SFTP
*/
-
public function getConnection()
{
if ($this->connection) {
@@ -118,9 +112,7 @@ public function getConnection()
return $this->connection = new SFTP($this->host, $this->port);
}
-
/**
- *
* /**
* Get the authentication object for login.
*
@@ -144,14 +136,13 @@ protected function getAuthForLogin()
// If a plain password was set on the auth credentials, we will just return
// that as it can be used to connect to the server. This will be used if
// there is no RSA key and it gets specified in the credential arrays.
- elseif (isset( $this->auth['password'] )) {
+ elseif (isset($this->auth['password'])) {
return $this->auth['password'];
}
throw new \InvalidArgumentException('Password / key is required.');
}
-
/**
* Determine if the SSH Agent should provide an RSA key.
*
@@ -159,10 +150,9 @@ protected function getAuthForLogin()
*/
protected function useAgent()
{
- return isset( $this->auth['agent'] ) && $this->auth['agent'] === true;
+ return isset($this->auth['agent']) && $this->auth['agent'] === true;
}
-
/**
* Get a new SSH Agent instance.
*
@@ -173,7 +163,6 @@ public function getAgent()
return new Agent();
}
-
/**
* Determine if an RSA key is configured.
*
@@ -181,12 +170,11 @@ public function getAgent()
*/
protected function hasRsaKey()
{
- $hasKey = ( isset( $this->auth['key'] ) && trim($this->auth['key']) != '' );
+ $hasKey = (isset($this->auth['key']) && trim($this->auth['key']) != '');
- return $hasKey || ( isset( $this->auth['keytext'] ) && trim($this->auth['keytext']) != '' );
+ return $hasKey || (isset($this->auth['keytext']) && trim($this->auth['keytext']) != '');
}
-
/**
* Load the RSA key instance.
*
@@ -201,7 +189,6 @@ protected function loadRsaKey(array $auth)
return $key;
}
-
/**
* Create a new RSA key instance.
*
@@ -216,7 +203,6 @@ protected function getKey(array $auth)
return $key;
}
-
/**
* Get a new RSA key instance.
*
@@ -227,7 +213,6 @@ public function getNewKey()
return new RSA();
}
-
/**
* Read the contents of the RSA key.
*
@@ -237,14 +222,13 @@ public function getNewKey()
*/
protected function readRsaKey(array $auth)
{
- if (isset( $auth['key'] )) {
+ if (isset($auth['key'])) {
return $this->files->get($auth['key']);
}
return $auth['keytext'];
}
-
/**
* Get timeout.
*
@@ -255,7 +239,6 @@ public function getTimeout()
return $this->timeout;
}
-
/*
* Delete a remote file from the server.
*
@@ -264,7 +247,6 @@ public function getTimeout()
* @return bool
*/
-
/**
* Set timeout.
*
@@ -279,7 +261,6 @@ protected function setTimeout($timeout)
$this->timeout = (int) $timeout;
}
-
/**
* Determine if the gateway is connected.
*
@@ -290,7 +271,6 @@ public function connected()
return $this->getConnection()->isConnected();
}
-
/**
* Run a command against the server (non-blocking).
*
@@ -303,7 +283,6 @@ public function run($command)
$this->getConnection()->exec($command, false);
}
-
/**
* Download the contents of a remote file.
*
@@ -317,7 +296,6 @@ public function get($remote, $local)
$this->getConnection()->get($remote, $local);
}
-
/**
* Get the contents of a remote file.
*
@@ -330,7 +308,6 @@ public function getString($remote)
return $this->getConnection()->get($remote);
}
-
/**
* Upload a local file to the server.
*
@@ -344,7 +321,6 @@ public function put($local, $remote)
$this->getConnection()->put($remote, $local, SFTP::SOURCE_LOCAL_FILE);
}
-
/**
* Upload a string to to the given file on the server.
*
@@ -358,7 +334,6 @@ public function putString($remote, $contents)
$this->getConnection()->put($remote, $contents);
}
-
/**
* Check whether a given file exists on the server.
*
@@ -371,7 +346,6 @@ public function exists($remote)
return $this->getConnection()->file_exists($remote);
}
-
/**
* Rename a remote file.
*
@@ -385,13 +359,11 @@ public function rename($remote, $newRemote)
return $this->getConnection()->rename($remote, $newRemote);
}
-
public function delete($remote)
{
return $this->getConnection()->delete($remote);
}
-
/**
* Get the next line of output from the server.
*
@@ -404,7 +376,6 @@ public function nextLine()
return $value === true ? null : $value;
}
-
/**
* Get the exit status of the last command.
*
@@ -415,7 +386,6 @@ public function status()
return $this->getConnection()->getExitStatus();
}
-
/**
* Get the host used by the gateway.
*
@@ -426,7 +396,6 @@ public function getHost()
return $this->host;
}
-
/**
* Get the port used by the gateway.
*
diff --git a/tests/RemoteSecLibTest.php b/tests/RemoteSecLibTest.php
index dc24e0e..e765253 100644
--- a/tests/RemoteSecLibTest.php
+++ b/tests/RemoteSecLibTest.php
@@ -33,7 +33,7 @@ public function testKeyTextCanBeSetManually()
'127.0.0.1:22',
['username' => 'taylor', 'keytext' => 'keystuff'],
$files,
- 10
+ 10,
])->makePartial();
$gateway->shouldReceive('getConnection')->andReturn(m::mock('StdClass'));
$gateway->shouldReceive('getNewKey')->andReturn($key = m::mock('StdClass'));
@@ -51,7 +51,7 @@ public function getGateway()
'127.0.0.1:22',
['username' => 'taylor', 'key' => 'keypath', 'keyphrase' => 'keyphrase'],
$files,
- 10
+ 10,
])->makePartial();
$gateway->shouldReceive('getConnection')->andReturn(m::mock('StdClass'));