Test Failed
Push — master ( eaa667...0d9623 )
by Evgenii
38:52
created
src/logic/processors/DbProcessor.php 1 patch
Braces   +9 added lines, -6 removed lines patch added patch discarded remove patch
@@ -58,13 +58,15 @@  discard block
 block discarded – undo
58 58
         $dsn = substr($dsn, strpos($dsn, ':') + 1);
59 59
         $dsnParts = explode(';', $dsn);
60 60
 
61
-        if (empty($dsnParts))
62
-            throw new DsnParseException();
61
+        if (empty($dsnParts)) {
62
+                    throw new DsnParseException();
63
+        }
63 64
 
64 65
         foreach ($dsnParts as $part) {
65 66
             $row = explode('=', $part);
66
-            if (isset($row[0]) && isset($row[1]))
67
-                $this->parsedDsn[$row[0]] = $row[1];
67
+            if (isset($row[0]) && isset($row[1])) {
68
+                            $this->parsedDsn[$row[0]] = $row[1];
69
+            }
68 70
         }
69 71
 
70 72
         $this->host = $this->parsedDsn['host'] ?: null;
@@ -74,8 +76,9 @@  discard block
 block discarded – undo
74 76
 
75 77
     protected function checkBinary(string $binary)
76 78
     {
77
-        if (!file_exists($binary) || !is_executable($binary))
78
-            throw new BinaryNotFoundException($binary);
79
+        if (!file_exists($binary) || !is_executable($binary)) {
80
+                    throw new BinaryNotFoundException($binary);
81
+        }
79 82
     }
80 83
 
81 84
     public function backup()
Please login to merge, or discard this patch.
src/logic/processors/PostgresProcessor.php 1 patch
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -15,8 +15,9 @@  discard block
 block discarded – undo
15 15
         $ionicePath = $this->module->binaries['ionice'];
16 16
         $command = "PGPASSWORD='{$this->password}' {$ionicePath} -c{$this->io} {$binaryPath} -h {$this->host} -p {$this->port} -U {$this->username} -Fc -Z1 {$this->database} -f {$this->backupFilePath}";
17 17
         exec($command, $return);
18
-        if (!empty($return))
19
-            throw new PostgresDumpException();
18
+        if (!empty($return)) {
19
+                    throw new PostgresDumpException();
20
+        }
20 21
     }
21 22
 
22 23
     public function restore()
@@ -24,8 +25,9 @@  discard block
 block discarded – undo
24 25
         $binaryPath = $this->module->binaries['pg_restore'];
25 26
         $command = "PGPASSWORD='{$this->password}' {$binaryPath} -c -Fc -j 4 -h {$this->host} -p {$this->port} -U {$this->username}  -d {$this->database} {$this->backupFilePath}";
26 27
         exec($command, $return);
27
-        if (!empty($return))
28
-            throw new PostgresDumpException();
28
+        if (!empty($return)) {
29
+                    throw new PostgresDumpException();
30
+        }
29 31
     }
30 32
 
31 33
     public function init()
Please login to merge, or discard this patch.
src/logic/BackupRestore.php 1 patch
Braces   +9 added lines, -6 removed lines patch added patch discarded remove patch
@@ -53,8 +53,9 @@  discard block
 block discarded – undo
53 53
     protected function loadConfigs()
54 54
     {
55 55
         $this->configs = Yii::$app->getModule('backup')->configs;
56
-        if (!is_array($this->configs) || !sizeof($this->configs))
57
-            throw new ModuleNotConfiguredException('Backup configs is empty');
56
+        if (!is_array($this->configs) || !sizeof($this->configs)) {
57
+                    throw new ModuleNotConfiguredException('Backup configs is empty');
58
+        }
58 59
     }
59 60
 
60 61
     /**
@@ -63,8 +64,9 @@  discard block
 block discarded – undo
63 64
      */
64 65
     protected function setUpActiveConfig()
65 66
     {
66
-        if (!is_array($this->configs[$this->config_id]))
67
-            throw new ConfigurationNotFoundException("Configuration `{$this->config_id}` not found.");
67
+        if (!is_array($this->configs[$this->config_id])) {
68
+                    throw new ConfigurationNotFoundException("Configuration `{$this->config_id}` not found.");
69
+        }
68 70
         $this->currentConfig = $this->configs[$this->config_id];
69 71
     }
70 72
 
@@ -76,8 +78,9 @@  discard block
 block discarded – undo
76 78
      */
77 79
     public function run()
78 80
     {
79
-        if (empty($this->currentConfig['io']))
80
-            $this->currentConfig['io'] = IOPriority::IDLE;
81
+        if (empty($this->currentConfig['io'])) {
82
+                    $this->currentConfig['io'] = IOPriority::IDLE;
83
+        }
81 84
 
82 85
         if ($this->currentConfig['type'] == BackupType::DB) {
83 86
             $this->connection = Yii::$app->{$this->currentConfig['connection']};
Please login to merge, or discard this patch.
src/logic/FolderBackupMaker.php 1 patch
Braces   +12 added lines, -8 removed lines patch added patch discarded remove patch
@@ -35,11 +35,13 @@  discard block
 block discarded – undo
35 35
      */
36 36
     public function __construct(string $backupFilePath, string $targetFolder, $io = IOPriority::IDLE)
37 37
     {
38
-        if (file_exists($backupFilePath))
39
-            throw new Exception("Backup file exists.");
38
+        if (file_exists($backupFilePath)) {
39
+                    throw new Exception("Backup file exists.");
40
+        }
40 41
 
41
-        if (!file_exists($targetFolder))
42
-            throw new Exception("Target folder not exists.");
42
+        if (!file_exists($targetFolder)) {
43
+                    throw new Exception("Target folder not exists.");
44
+        }
43 45
 
44 46
         $this->module = Yii::$app->getModule('backup');
45 47
         $this->backupFilePath = $backupFilePath;
@@ -58,11 +60,13 @@  discard block
 block discarded – undo
58 60
         $zipPath = $this->module->binaries['zip'];
59 61
         $command = "cd {$this->targetFolder} && {$ionicePath} -c{$this->io} {$zipPath} -r -0 {$this->backupFilePath} * > /dev/null";
60 62
         exec($command);
61
-        if (!file_exists($this->backupFilePath))
62
-            throw new FolderDumpException();
63
+        if (!file_exists($this->backupFilePath)) {
64
+                    throw new FolderDumpException();
65
+        }
63 66
 
64
-        if ($this->module->chmod)
65
-            chmod($this->backupFilePath, $this->module->chmod);
67
+        if ($this->module->chmod) {
68
+                    chmod($this->backupFilePath, $this->module->chmod);
69
+        }
66 70
 
67 71
         return true;
68 72
     }
Please login to merge, or discard this patch.
src/logic/BackupImporter.php 1 patch
Braces   +9 added lines, -6 removed lines patch added patch discarded remove patch
@@ -34,14 +34,17 @@
 block discarded – undo
34 34
     {
35 35
         $this->module = Yii::$app->getModule('backup');
36 36
 
37
-        if (!file_exists($absoluteFilePath))
38
-            throw new FileNotFoundException();
37
+        if (!file_exists($absoluteFilePath)) {
38
+                    throw new FileNotFoundException();
39
+        }
39 40
 
40
-        if (!is_array($this->module->configs) || empty($this->module->configs))
41
-            throw new ModuleNotConfiguredException();
41
+        if (!is_array($this->module->configs) || empty($this->module->configs)) {
42
+                    throw new ModuleNotConfiguredException();
43
+        }
42 44
 
43
-        if (!is_array($this->module->configs[$config_id]))
44
-            throw new ConfigurationNotFoundException();
45
+        if (!is_array($this->module->configs[$config_id])) {
46
+                    throw new ConfigurationNotFoundException();
47
+        }
45 48
 
46 49
         $this->currentConfig = $this->module->configs[$config_id];
47 50
         $this->model = new Backup();
Please login to merge, or discard this patch.
src/controllers/ConsoleController.php 1 patch
Braces   +14 added lines, -10 removed lines patch added patch discarded remove patch
@@ -52,8 +52,9 @@  discard block
 block discarded – undo
52 52
     public function actionRestore(string $backup_id)
53 53
     {
54 54
         $model = Backup::findOne((int)$backup_id);
55
-        if (!$model)
56
-            throw new ErrorException('Backup not found.');
55
+        if (!$model) {
56
+                    throw new ErrorException('Backup not found.');
57
+        }
57 58
 
58 59
         Yii::createObject(BackupRestore::class, [$model])->run();
59 60
         $this->stdout('Backup restored.' . PHP_EOL, Console::FG_GREEN);
@@ -69,14 +70,16 @@  discard block
 block discarded – undo
69 70
     {
70 71
         $models = Backup::find()->orderBy('id DESC')->all();
71 72
 
72
-        if (empty($models))
73
-            return $this->stderr('Backups not found.' . PHP_EOL, Console::FG_YELLOW);
73
+        if (empty($models)) {
74
+                    return $this->stderr('Backups not found.' . PHP_EOL, Console::FG_YELLOW);
75
+        }
74 76
 
75
-        foreach ($models as $model)
76
-            $this->stdout("{$model->id}: " . Yii::$app->formatter->asDatetime($model->date) . "\t\t{$model->config_id}\t\t" .
77
+        foreach ($models as $model) {
78
+                    $this->stdout("{$model->id}: " . Yii::$app->formatter->asDatetime($model->date) . "\t\t{$model->config_id}\t\t" .
77 79
                 BackupType::$list[$model->type] .
78 80
                 PHP_EOL,
79 81
                 $model->status ? Console::FG_GREEN : Console::FG_RED);
82
+        }
80 83
     }
81 84
 
82 85
     /**
@@ -89,9 +92,10 @@  discard block
 block discarded – undo
89 92
     public function actionImport(string $config_id, string $absoluteFilePath)
90 93
     {
91 94
         $importer = new BackupImporter($config_id, $absoluteFilePath);
92
-        if ($importer->import())
93
-            $this->stdout("Backup imported: {$absoluteFilePath}\n", Console::FG_GREEN);
94
-        else
95
-            $this->stdout("Something went wrong.\n", Console::FG_RED);
95
+        if ($importer->import()) {
96
+                    $this->stdout("Backup imported: {$absoluteFilePath}\n", Console::FG_GREEN);
97
+        } else {
98
+                    $this->stdout("Something went wrong.\n", Console::FG_RED);
99
+        }
96 100
     }
97 101
 }
Please login to merge, or discard this patch.
src/controllers/AdminController.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -148,8 +148,9 @@
 block discarded – undo
148 148
     protected function getBackup(int $id)
149 149
     {
150 150
         $this->model = Backup::findOne($id);
151
-        if (!$this->model)
152
-            throw new NotFoundHttpException(Yii::t('app.f12.backup', 'Backup is not found.'));
151
+        if (!$this->model) {
152
+                    throw new NotFoundHttpException(Yii::t('app.f12.backup', 'Backup is not found.'));
153
+        }
153 154
     }
154 155
 
155 156
 }
Please login to merge, or discard this patch.