Avoid variables with short names and unused functions

This commit is contained in:
Shikiryu 2016-06-29 21:31:16 +02:00
parent 180765af3c
commit ffdf0b8476
3 changed files with 15 additions and 67 deletions

View File

@ -7,8 +7,8 @@ use Shikiryu\Backup\Backup\BackupAbstract;
class Email extends TransportAbstract
{
private $to;
private $from;
private $email_to;
private $email_from;
private $encoding;
private $subject;
private $message;
@ -149,66 +149,14 @@ class Email extends TransportAbstract
parent::__construct($backup, $config);
$this->setFiles($this->backup->getFilesToBackup());
$this->setStreams($this->backup->getStreamsToBackup());
$this->to = $this->config['to'];
$this->from = $this->config['from'];
$this->email_to = $this->config['to'];
$this->email_from = $this->config['from'];
$this->encoding = $this->config['encoding'];
$this->subject = $this->config['subject'];
$this->message = $this->config['message'];
$this->encoding = $this->config['encoding'];
}
/**
* Add a recipient
*
* @param string $to
*
* @return $this
*/
private function addTo($to)
{
$this->to = $to;
return $this;
}
/**
* Add the sender
*
* @param $from
*
* @return $this
*/
private function setFrom($from)
{
$this->from = $from;
return $this;
}
/**
* Add the subject
*
* @param $sub
*
* @return $this
*/
private function setSubject($sub)
{
$this->subject = strip_tags($sub);
return $this;
}
/**
* Add the message (in text)
*
* @param $mes
*
* @return $this
*/
private function setMessage($mes)
{
$this->message = strip_tags($mes);
return $this;
}
private function setFiles($files = array())
{
if (is_array($files) && !empty($files)) {
@ -255,7 +203,7 @@ class Email extends TransportAbstract
$this->files = array(TEMP_DIR.$zip_name=>$zip_name);
$random_hash = md5(date('r', time()));
$headers = "From: " . $this->from . "\r\nReply-To: " . $this->from;
$headers = "From: " . $this->email_from . "\r\nReply-To: " . $this->email_from;
$headers .= "\r\nMIME-Version: 1.0\r\nContent-Type: multipart/mixed; boundary=\"" . $random_hash . "\"";
$output = "
@ -288,7 +236,7 @@ Content-Disposition: attachment; filename=" . $name . "
" . chunk_split(base64_encode($stream));
}
$output.="--$random_hash--";
return mail($this->to, $this->subject, $output, $headers);
return mail($this->email_to, $this->subject, $output, $headers);
}
}

View File

@ -56,19 +56,19 @@ abstract class BackupAbstract
/**
* Check if all files got the minimum given size.
*
* @param int $fs
* @param int $file_size
*
* @return bool
*/
public function checkMinimumFilesize($fs)
public function checkMinimumFilesize($file_size)
{
foreach ($this->_filesToBackup as $file => $name) {
if (filesize($file) < $fs) {
if (filesize($file) < $file_size) {
return false;
}
}
foreach ($this->_streamsToBackup as $name => $file) {
if (mb_strlen($file, 'utf-8') < $fs) {
if (mb_strlen($file, 'utf-8') < $file_size) {
return false;
}
}

View File

@ -15,7 +15,7 @@ class Mysql extends BackupAbstract
*/
protected $tables;
protected $host;
protected $db;
protected $database;
protected $login;
protected $pwd;
@ -35,7 +35,7 @@ class Mysql extends BackupAbstract
if(!empty($tables)) {
$this->tables = $tables;
}
$this->_streamsToBackup[sprintf('db-%s.sql', $this->db)] = $this->getFromTables();
$this->_streamsToBackup[sprintf('db-%s.sql', $this->database)] = $this->getFromTables();
return $this;
}
@ -49,7 +49,7 @@ class Mysql extends BackupAbstract
foreach($this->pdo->query('SHOW TABLES') as $table) {
$this->tables[] = $table;
}
$this->_streamsToBackup[sprintf('db-%s.sql', $this->db)] = $this->getFromTables();
$this->_streamsToBackup[sprintf('db-%s.sql', $this->database)] = $this->getFromTables();
return $this;
}
@ -71,7 +71,7 @@ class Mysql extends BackupAbstract
$result2->execute();
$row2 = $result2->fetch();
$return.= "\n\n" . $row2[1] . ";\n\n";
foreach($result as $i=>$row){
foreach($result as $row){
$return.= 'INSERT INTO ' . $table . ' VALUES(';
for ($j = 0; $j < $num_fields; $j++) {
$row[$j] = addslashes($row[$j]);
@ -102,7 +102,7 @@ class Mysql extends BackupAbstract
protected function preBuild()
{
$this->pdo = new \PDO('mysql:host='.$this->host.';dbname='.$this->db, $this->login, $this->pwd);
$this->pdo = new \PDO('mysql:host='.$this->host.';dbname='.$this->database, $this->login, $this->pwd);
}
protected function postBuild()