Completed
Push — master ( 18ebf0...848848 )
by claudio
08:43
created
app/Console/Commands/Optimise/OptimiseCommand.php 1 patch
Braces   +21 added lines, -16 removed lines patch added patch discarded remove patch
@@ -58,10 +58,11 @@  discard block
 block discarded – undo
58 58
         //TODO insert a timeout
59 59
         //TODO try...catch with destruct
60 60
         $companyId = $this->argument('companyId');
61
-        if (is_numeric($companyId))
62
-            $this->makeForeground(Company::findOrFail($companyId));
63
-        else
64
-            $this->syncAll();
61
+        if (is_numeric($companyId)) {
62
+                    $this->makeForeground(Company::findOrFail($companyId));
63
+        } else {
64
+                    $this->syncAll();
65
+        }
65 66
     }
66 67
 
67 68
     /**
@@ -74,12 +75,13 @@  discard block
 block discarded – undo
74 75
         try {
75 76
             (new Optimise($company, $this->schedule, $this->laravel))->optimise()->save();
76 77
             $this->info('Optimisation ' . $company->id . ' completed');
77
-        }catch(OptimiseException $e){
78
-            if($e->isEmpty())
79
-                $this->warn('Company ' . $company->id . ' has no sufficient data');
80
-            else
81
-                $this->error('Error during optimisation of company ' . $company->id .': '. $e->getMessage());
82
-        }catch(\Exception $e) {
78
+        } catch(OptimiseException $e){
79
+            if($e->isEmpty()) {
80
+                            $this->warn('Company ' . $company->id . ' has no sufficient data');
81
+            } else {
82
+                            $this->error('Error during optimisation of company ' . $company->id .': '. $e->getMessage());
83
+            }
84
+        } catch(\Exception $e) {
83 85
             $this->error('Error during optimisation of company ' . $company->id .': '. $e->getMessage());
84 86
         }
85 87
     }
@@ -90,13 +92,15 @@  discard block
 block discarded – undo
90 92
         if ($this->option('background')) {
91 93
             \Log::debug(self::BACKGROUND_MOD_MEX);
92 94
             $this->info(self::BACKGROUND_MOD_MEX);
93
-            foreach ($companies as $company)
94
-                $this->makeBackground($company);
95
+            foreach ($companies as $company) {
96
+                            $this->makeBackground($company);
97
+            }
95 98
             \Log::debug(self::BACKGROUND_COMPLETED_MEX);
96 99
             $this->info(self::BACKGROUND_COMPLETED_MEX);
97
-        } else
98
-            foreach ($companies as $company)
100
+        } else {
101
+                    foreach ($companies as $company)
99 102
                 $this->makeForeground($company);
103
+        }
100 104
     }
101 105
 
102 106
     /**
@@ -106,7 +110,8 @@  discard block
 block discarded – undo
106 110
     private function makeBackground(Company $company)
107 111
     {
108 112
         $event = $this->schedule->command('optimise:meetings ' . $company->id)->withoutOverlapping();
109
-        if ($event->isDue($this->laravel))
110
-            $event->run($this->laravel);
113
+        if ($event->isDue($this->laravel)) {
114
+                    $event->run($this->laravel);
115
+        }
111 116
     }
112 117
 }
Please login to merge, or discard this patch.