Test Failed
Push — master ( eaa667...0d9623 )
by Evgenii
38:52
created
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.