mirror of
https://github.com/Chouchen/Shikiryu_Backup.git
synced 2021-06-30 16:02:14 +02:00
💚 Update rules for PHPMD
This commit is contained in:
@@ -2,7 +2,9 @@
|
||||
|
||||
namespace Shikiryu\Backup\Transport;
|
||||
|
||||
use Exception;
|
||||
use Shikiryu\Backup\Backup\BackupAbstract;
|
||||
use ZIPARCHIVE;
|
||||
|
||||
class Email extends TransportAbstract
|
||||
{
|
||||
@@ -194,7 +196,7 @@ class Email extends TransportAbstract
|
||||
*
|
||||
* @see #mail
|
||||
* @return bool
|
||||
* @throws \Exception
|
||||
* @throws Exception
|
||||
*/
|
||||
public function send()
|
||||
{
|
||||
@@ -202,9 +204,9 @@ class Email extends TransportAbstract
|
||||
// TODO check if file is empty
|
||||
|
||||
// Checking files are selected
|
||||
$zip = new \ZipArchive(); // Load zip library
|
||||
$zip = new ZipArchive(); // Load zip library
|
||||
$zip_name = time(). '.zip'; // Zip name
|
||||
if ($zip->open(TEMP_DIR.$zip_name, \ZIPARCHIVE::CREATE)===true) {
|
||||
if ($zip->open(TEMP_DIR.$zip_name, ZIPARCHIVE::CREATE)===true) {
|
||||
if (!empty($this->files)) {
|
||||
foreach ($this->files as $file => $name) {
|
||||
$zip->addFile($file, $name); // Adding files into zip
|
||||
@@ -212,7 +214,7 @@ class Email extends TransportAbstract
|
||||
}
|
||||
$zip->close();
|
||||
} else {
|
||||
throw new \Exception('Transport::Email::Can\'t zip the given backup.');
|
||||
throw new Exception('Transport::Email::Can\'t zip the given backup.');
|
||||
}
|
||||
|
||||
$this->files = array(TEMP_DIR.$zip_name=>$zip_name);
|
||||
|
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace Shikiryu\Backup\Transport;
|
||||
|
||||
use Exception;
|
||||
|
||||
class Ftp extends TransportAbstract
|
||||
{
|
||||
|
||||
@@ -26,13 +28,13 @@ class Ftp extends TransportAbstract
|
||||
|
||||
$this->connection = ftp_connect($this->host);
|
||||
if ($this->connection === false) {
|
||||
throw new \Exception(sprintf('I can\'t connect to the FTP %s', $this->host));
|
||||
throw new Exception(sprintf('I can\'t connect to the FTP %s', $this->host));
|
||||
}
|
||||
|
||||
$login = @ftp_login($this->connection, $this->login, $this->password);
|
||||
$login = ftp_login($this->connection, $this->login, $this->password);
|
||||
if ($login === false) {
|
||||
$msg = sprintf('Connexion FTP %s refusée avec %s et %s', $this->host, $this->login, $this->password);
|
||||
throw new \Exception($msg);
|
||||
throw new Exception($msg);
|
||||
}
|
||||
|
||||
$this->setFiles($this->backup->getFilesToBackup());
|
||||
@@ -57,7 +59,7 @@ class Ftp extends TransportAbstract
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
* @throws \Exception
|
||||
* @throws Exception
|
||||
*/
|
||||
public function send()
|
||||
{
|
||||
@@ -89,7 +91,7 @@ class Ftp extends TransportAbstract
|
||||
}
|
||||
|
||||
if (!$sent) {
|
||||
throw new \Exception('At least an upload didnt work.');
|
||||
throw new Exception('At least an upload didnt work.');
|
||||
}
|
||||
|
||||
return $sent;
|
||||
|
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Shikiryu\Backup\Transport;
|
||||
|
||||
use Exception;
|
||||
use Shikiryu\Backup\Backup\BackupAbstract;
|
||||
|
||||
class Folder extends TransportAbstract
|
||||
@@ -25,7 +26,7 @@ class Folder extends TransportAbstract
|
||||
/**
|
||||
* @return bool
|
||||
*
|
||||
* @throws \Exception
|
||||
* @throws Exception
|
||||
*/
|
||||
public function send()
|
||||
{
|
||||
@@ -35,7 +36,7 @@ class Folder extends TransportAbstract
|
||||
if ($this->backup->isLocal()) {
|
||||
foreach ($this->backup->getFilesToBackup() as $file => $name) {
|
||||
if (copy($file, $this->folder . $name) === false) {
|
||||
throw new \Exception(sprintf('Copy of %s in %s failed', $name, $this->folder));
|
||||
throw new Exception(sprintf('Copy of %s in %s failed', $name, $this->folder));
|
||||
}
|
||||
}
|
||||
foreach ($this->backup->getStreamsToBackup() as $name => $file) {
|
||||
@@ -43,7 +44,7 @@ class Folder extends TransportAbstract
|
||||
$name = 'backup' . $name . '.txt';
|
||||
}
|
||||
if (file_put_contents($this->folder . $name, $file) === false) {
|
||||
throw new \Exception(sprintf('Saving of %s in %s failed', $name, $this->folder));
|
||||
throw new Exception(sprintf('Saving of %s in %s failed', $name, $this->folder));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -2,7 +2,9 @@
|
||||
|
||||
namespace Shikiryu\Backup\Transport;
|
||||
|
||||
use Exception;
|
||||
use phpseclib\Net\SFTP as LibSFTP;
|
||||
use Shikiryu\Backup\Backup\BackupAbstract;
|
||||
|
||||
class Sftp extends TransportAbstract
|
||||
{
|
||||
@@ -20,9 +22,9 @@ class Sftp extends TransportAbstract
|
||||
private $connection;
|
||||
|
||||
/**
|
||||
* @param \Shikiryu\Backup\Backup\BackupAbstract $backup
|
||||
* @param BackupAbstract $backup
|
||||
* @param array $config
|
||||
* @throws \Exception
|
||||
* @throws Exception
|
||||
*/
|
||||
public function __construct($backup, $config)
|
||||
{
|
||||
@@ -30,14 +32,14 @@ class Sftp extends TransportAbstract
|
||||
|
||||
$this->connection = new LibSFTP($this->host, $this->port);
|
||||
if (!$this->connection->login($this->login, $this->password)) {
|
||||
throw new \Exception(sprintf('I can\'t connect to the FTP %s', $this->host));
|
||||
throw new Exception(sprintf('I can\'t connect to the FTP %s', $this->host));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*
|
||||
* @throws \Exception
|
||||
* @throws Exception
|
||||
*/
|
||||
public function send()
|
||||
{
|
||||
@@ -65,7 +67,7 @@ class Sftp extends TransportAbstract
|
||||
}
|
||||
|
||||
if (!$sent) {
|
||||
throw new \Exception('At least an upload didnt work.');
|
||||
throw new Exception('At least an upload didnt work.');
|
||||
}
|
||||
return $sent;
|
||||
}
|
||||
|
Reference in New Issue
Block a user