Skip to content
Snippets Groups Projects
Commit 2d8629a8 authored by Borut Piletic's avatar Borut Piletic
Browse files

Rename method isSecure()

parent df73d309
No related branches found
No related tags found
1 merge request!15SFTP support
......@@ -66,7 +66,7 @@ class FTPClient implements FTPClientInterface {
$this->settings = $settings;
}
if ($this->isSecure()) {
if ($this->isSecureConnection()) {
$this->connection = new SFTP($this->settings['advanced']['hostname']);
if (!$this->connection->login($this->settings['username'], $this->settings['password'])) {
throw new \Exception('Failed to connect to SFTP server.');
......@@ -102,7 +102,7 @@ class FTPClient implements FTPClientInterface {
* {@inheritdoc}
*/
public function closeConnection(): void {
if ($this->isSecure()) {
if ($this->isSecureConnection()) {
$this->connection ?? $this->connection->disconnect();
}
else {
......@@ -114,7 +114,7 @@ class FTPClient implements FTPClientInterface {
* {@inheritdoc}
*/
public function list(string $directory = '.', bool $fullpath = TRUE): array {
$list = ($this->isSecure()) ? $this->connection->nlist($directory) : ftp_nlist($this->connection, $directory);
$list = ($this->isSecureConnection()) ? $this->connection->nlist($directory) : ftp_nlist($this->connection, $directory);
if (!$list) {
throw new \Exception('Failed to list the FTP directory: ' . $directory);
}
......@@ -138,7 +138,7 @@ class FTPClient implements FTPClientInterface {
throw new \Exception('Could not create the destination path: ' . $destination_path);
}
if ($this->isSecure()) {
if ($this->isSecureConnection()) {
return $this->connection->get($source_file, $destination_file);
}
else {
......@@ -169,7 +169,7 @@ class FTPClient implements FTPClientInterface {
* {@inheritdoc}
*/
public function getDirectory(string $source, string $destination): void {
if ($this->isSecure()) {
if ($this->isSecureConnection()) {
throw new \Exception("FTPClient::getDirectory() is not supported for SFTP connections.");
}
......@@ -277,7 +277,7 @@ class FTPClient implements FTPClientInterface {
/**
* {@inheritdoc}
*/
public function isSecure(): bool {
public function isSecureConnection(): bool {
return (isset($this->settings['connection']) && $this->settings['connection'] === 'sftp');
}
......
......@@ -78,6 +78,6 @@ interface FTPClientInterface {
* @return bool
* TRUE if SFTP connection is being used, FALSE otherwise.
*/
public function isSecure(): bool;
public function isSecureConnection(): bool;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment