Completed
Pull Request — master (#28)
by claudio
07:42 queued 01:16
created
app/MeetingTimeslot.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@
 block discarded – undo
11 11
      *
12 12
      * @var array
13 13
      */
14
-    protected $fillable = ['time_start', 'time_end'];
14
+    protected $fillable = [ 'time_start', 'time_end' ];
15 15
 
16 16
     public function employees()
17 17
     {
Please login to merge, or discard this patch.
app/Http/Controllers/Employees/Calendars/CalendarsController.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -17,8 +17,8 @@  discard block
 block discarded – undo
17 17
      */
18 18
     public function __construct()
19 19
     {
20
-        config(['auth.model' => \plunner\Employee::class]);
21
-        config(['jwt.user' => \plunner\Employee::class]);
20
+        config([ 'auth.model' => \plunner\Employee::class ]);
21
+        config([ 'jwt.user' => \plunner\Employee::class ]);
22 22
         $this->middleware('jwt.authandrefresh:mode-en');
23 23
     }
24 24
 
@@ -66,8 +66,8 @@  discard block
 block discarded – undo
66 66
         $employee = \Auth::user();
67 67
         $input = $request->all();
68 68
         $calendar = $employee->calendars()->create($input);
69
-        if(isset($input['password']))
70
-            $input['password'] = \Crypt::encrypt($input['password']);
69
+        if (isset($input[ 'password' ]))
70
+            $input[ 'password' ] = \Crypt::encrypt($input[ 'password' ]);
71 71
         $calendar->caldav()->create($input);
72 72
         //TODO test
73 73
         //TODO validator
@@ -104,17 +104,17 @@  discard block
 block discarded – undo
104 104
         $this->authorize($calendar);
105 105
         $input = $request->all();
106 106
         $caldav = $calendar->caldav;
107
-        if($caldav){
107
+        if ($caldav) {
108 108
             $this->validateCaldav($request);
109 109
         }
110
-        if(isset($input['password']))
111
-            $input['password'] = \Crypt::encrypt($input['password']);
110
+        if (isset($input[ 'password' ]))
111
+            $input[ 'password' ] = \Crypt::encrypt($input[ 'password' ]);
112 112
         $calendar->update($input);
113 113
         //TODO test
114 114
         //TODO validator
115 115
         //TODO check if caldav exists?
116 116
 
117
-        if($caldav)
117
+        if ($caldav)
118 118
             $caldav->update($input);
119 119
         return $calendar;
120 120
     }
@@ -148,9 +148,9 @@  discard block
 block discarded – undo
148 148
             $caldavClient->connect($request->input('url'), $request->input('username'), $request->input('password'));
149 149
             $calendars = $caldavClient->findCalendars();
150 150
             return array_keys($calendars);
151
-        }catch (\it\thecsea\caldav_client_adapter\CaldavException $e)
151
+        } catch (\it\thecsea\caldav_client_adapter\CaldavException $e)
152 152
         {
153
-            return Response::json(['error' => $e->getMessage()],422);
153
+            return Response::json([ 'error' => $e->getMessage() ], 422);
154 154
         }
155 155
     }
156 156
 
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
         $this->validate($request, [
163 163
             'url' => 'required|max:255',
164 164
             'username' => 'required|max:255',
165
-            'password' => ((\Route::current()->getName() == 'companies.calendars.caldav')?'required':''),
165
+            'password' => ((\Route::current()->getName() == 'companies.calendars.caldav') ? 'required' : ''),
166 166
             'calendar_name' => 'required|max:255',
167 167
         ]);
168 168
     }
Please login to merge, or discard this patch.
app/Employee.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -50,14 +50,14 @@  discard block
 block discarded – undo
50 50
      *
51 51
      * @var array
52 52
      */
53
-    protected $fillable = ['name', 'email', 'password'];
53
+    protected $fillable = [ 'name', 'email', 'password' ];
54 54
 
55 55
     /**
56 56
      * The attributes excluded from the model's JSON form.
57 57
      *
58 58
      * @var array
59 59
      */
60
-    protected $hidden = ['password', 'remember_token', 'pivot'];
60
+    protected $hidden = [ 'password', 'remember_token', 'pivot' ];
61 61
 
62 62
     /**
63 63
      * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
      * to get all meetings where the user can go user groups with meetings
89 89
      * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
90 90
      */
91
-    public function meetings(){
91
+    public function meetings() {
92 92
         //TODO durign the inserting chek if the meeting is of a group of the user
93 93
         return $this->belongsToMany(Meeting::class);
94 94
     }
@@ -104,16 +104,16 @@  discard block
 block discarded – undo
104 104
     public function getEmailForPasswordReset()
105 105
     {
106 106
         list(, $caller) = debug_backtrace(false);
107
-        if(isset($caller['class']))
108
-            $caller = explode('\\', $caller['class']);
107
+        if (isset($caller[ 'class' ]))
108
+            $caller = explode('\\', $caller[ 'class' ]);
109 109
         else
110 110
             $caller = '';
111 111
 
112 112
         //check if this function is called by email sender
113
-        if ((count($caller) && $caller[count($caller) - 1] == 'PasswordBroker') || (defined('HHVM_VERSION') && $caller == ''))
113
+        if ((count($caller) && $caller[ count($caller) - 1 ] == 'PasswordBroker') || (defined('HHVM_VERSION') && $caller == ''))
114 114
             return $this->email;
115 115
         //return unique identify for token repository
116
-        return $this->email . $this->company->id;
116
+        return $this->email.$this->company->id;
117 117
     }
118 118
 
119 119
     /**
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
     public function belongsToGroup(Group $group)
124 124
     {
125 125
         $group = $this->groups()->where('id', $group->id)->first();
126
-        if(is_object($group) && $group->exists)
126
+        if (is_object($group) && $group->exists)
127 127
             return true;
128 128
         return false;
129 129
     }
Please login to merge, or discard this patch.
app/Meeting.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -46,14 +46,14 @@
 block discarded – undo
46 46
      *
47 47
      * @var array
48 48
      */
49
-    protected $fillable = ['title', 'description', 'duration'];
49
+    protected $fillable = [ 'title', 'description', 'duration' ];
50 50
 
51 51
     /**
52 52
      * The attributes excluded from the model's JSON form.
53 53
      *
54 54
      * @var array
55 55
      */
56
-    protected $hidden = ['pivot'];
56
+    protected $hidden = [ 'pivot' ];
57 57
 
58 58
 
59 59
     /**
Please login to merge, or discard this patch.
app/Events/Caldav/OkEvent.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -39,6 +39,6 @@
 block discarded – undo
39 39
      */
40 40
     public function broadcastOn()
41 41
     {
42
-        return [];
42
+        return [ ];
43 43
     }
44 44
 }
Please login to merge, or discard this patch.
app/Console/Commands/Optimise/Optimise.php 1 patch
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
     {
86 86
         $this->startTime = clone $startTime;
87 87
         $this->endTime = clone $this->startTime;
88
-        $this->endTime->add(new \DateInterval('PT'.(($this->max_time_slots+$this->time_slots)*self::TIME_SLOT_DURATION).'S'));
88
+        $this->endTime->add(new \DateInterval('PT'.(($this->max_time_slots + $this->time_slots) * self::TIME_SLOT_DURATION).'S'));
89 89
     }
90 90
 
91 91
     /**
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
      */
170 170
     public function save()
171 171
     {
172
-        if(!($this->solver instanceof Solver)) {
172
+        if (!($this->solver instanceof Solver)) {
173 173
             \Event::fire(new ErrorEvent($this->company, 'solver is not an instace of Solver'));
174 174
             return;
175 175
         }
@@ -186,8 +186,8 @@  discard block
 block discarded – undo
186 186
     private function saveMeetings(Solver $solver)
187 187
     {
188 188
         $meetings = $solver->getYResults();
189
-        foreach($meetings as $id=>$meeting){
190
-            $meetingO = \plunner\Meeting::findOrFail($id);//TODO catch error
189
+        foreach ($meetings as $id=>$meeting) {
190
+            $meetingO = \plunner\Meeting::findOrFail($id); //TODO catch error
191 191
             $meetingO->start_time = $this->toDateTime(array_search('1', $meeting));
192 192
             $meetingO->save();
193 193
         }
@@ -199,11 +199,11 @@  discard block
 block discarded – undo
199 199
     private function saveEmployeesMeetings(Solver $solver)
200 200
     {
201 201
         $employeesMeetings = $solver->getXResults();
202
-        foreach($employeesMeetings as $eId =>$employeeMeetings)
202
+        foreach ($employeesMeetings as $eId =>$employeeMeetings)
203 203
         {
204 204
             $employee = \plunner\Employee::findOrFail($eId);
205 205
             $employeeMeetings = collect($employeeMeetings);
206
-            $employeeMeetings = $employeeMeetings->filter(function ($item) {
206
+            $employeeMeetings = $employeeMeetings->filter(function($item) {
207 207
                 return $item == 1;
208 208
             });
209 209
             $employee->meetings()->attach($employeeMeetings->keys()->toArray());
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
                 return $this->timeSlotsConverter($item);
265 265
             });
266 266
         return $solver->setMeetings($timeslots->keys()->toArray())
267
-            ->setMeetingsDuration($meetings->pluck('duration','id')->toArray())
267
+            ->setMeetingsDuration($meetings->pluck('duration', 'id')->toArray())
268 268
             ->setMeetingsAvailability(self::getAvailabilityArray($timeslots, $this->time_slots));
269 269
     }
270 270
 
@@ -310,15 +310,15 @@  discard block
 block discarded – undo
310 310
      */
311 311
     static private function getUsersMeetingsArray($users, $meetings, \Illuminate\Support\Collection $usersMeetings)
312 312
     {
313
-        $ret = [];
314
-        foreach($users as $user)
313
+        $ret = [ ];
314
+        foreach ($users as $user)
315 315
         {
316 316
             $usersMeetingsTmp = $usersMeetings->get($user);
317
-            foreach($meetings as $meeting){
318
-                if($usersMeetingsTmp->contains('meeting_id', $meeting)){
319
-                    $ret[$user][$meeting] = 1;
320
-                }else{
321
-                    $ret[$user][$meeting] = 0;
317
+            foreach ($meetings as $meeting) {
318
+                if ($usersMeetingsTmp->contains('meeting_id', $meeting)) {
319
+                    $ret[ $user ][ $meeting ] = 1;
320
+                } else {
321
+                    $ret[ $user ][ $meeting ] = 0;
322 322
                 }
323 323
             }
324 324
         }
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
 
329 329
     private function timeSlotsConverter($item)
330 330
     {
331
-        return $item->each(function($item2){
331
+        return $item->each(function($item2) {
332 332
             $item2->time_start = $this->toTimeSlot($item2->time_start);
333 333
             $item2->time_end = $this->toTimeSlot($item2->time_end);
334 334
             return $item2;
@@ -341,13 +341,13 @@  discard block
 block discarded – undo
341 341
      * @param bool|true $free if true the array is filled with 1 for timeslots values else with 0 for timeslots values
342 342
      * @return array
343 343
      */
344
-    static private function getAvailabilityArray(\Illuminate\Support\Collection $timeSlots, $timeslotsN, $free=true)
344
+    static private function getAvailabilityArray(\Illuminate\Support\Collection $timeSlots, $timeslotsN, $free = true)
345 345
     {
346
-        $ret = [];
347
-        foreach($timeSlots as $id=>$timeSlots2)
346
+        $ret = [ ];
347
+        foreach ($timeSlots as $id=>$timeSlots2)
348 348
         {
349
-            $ret = self::fillTimeSlots($ret, $id, $timeSlots2, $free?'1':'0');
350
-            $ret = self::fillRow($ret, $id, $timeslotsN, $free?'0':'1');
349
+            $ret = self::fillTimeSlots($ret, $id, $timeSlots2, $free ? '1' : '0');
350
+            $ret = self::fillRow($ret, $id, $timeslotsN, $free ? '0' : '1');
351 351
         }
352 352
 
353 353
         return $ret;
@@ -362,10 +362,10 @@  discard block
 block discarded – undo
362 362
      */
363 363
     static private function fillTimeSlots(array $array, $id, \Illuminate\Support\Collection $timeSlots, $fill = '0')
364 364
     {
365
-        foreach($timeSlots as $timeSlot) {
366
-            if(!isset($array[$id]))
367
-                $array[$id] = [];
368
-            $array[$id] = self::arrayPadInterval($array[$id], $timeSlot->time_start, $timeSlot->time_end, $fill);
365
+        foreach ($timeSlots as $timeSlot) {
366
+            if (!isset($array[ $id ]))
367
+                $array[ $id ] = [ ];
368
+            $array[ $id ] = self::arrayPadInterval($array[ $id ], $timeSlot->time_start, $timeSlot->time_end, $fill);
369 369
         }
370 370
         return $array;
371 371
     }
@@ -378,9 +378,9 @@  discard block
 block discarded – undo
378 378
      */
379 379
     static private function fillRow(array $array, $id, $until, $fill = '0')
380 380
     {
381
-        for($i = 1; $i <= $until; $i++){
382
-            if(!isset($array[$id][$i]))
383
-                $array[$id][$i] = $fill;
381
+        for ($i = 1; $i <= $until; $i++) {
382
+            if (!isset($array[ $id ][ $i ]))
383
+                $array[ $id ][ $i ] = $fill;
384 384
         }
385 385
 
386 386
         return $array;
@@ -395,8 +395,8 @@  discard block
 block discarded – undo
395 395
      */
396 396
     static private function arrayPadInterval(array $array, $from, $to, $pad = '0')
397 397
     {
398
-        for($i = $from; $i<$to; $i++)
399
-            $array[$i] = $pad;
398
+        for ($i = $from; $i < $to; $i++)
399
+            $array[ $i ] = $pad;
400 400
         return $array;
401 401
     }
402 402
 
@@ -410,14 +410,14 @@  discard block
 block discarded – undo
410 410
     {
411 411
         $dateTime = new \DateTime($time);
412 412
         $diff = $dateTime->diff($this->startTime);
413
-        $diff = explode(':',$diff->format('%R:%d:%h:%i:%s'));
414
-        $diff = $diff[1]*86400 + $diff[2]*3600 + $diff[3]*60 + $diff[4];
413
+        $diff = explode(':', $diff->format('%R:%d:%h:%i:%s'));
414
+        $diff = $diff[ 1 ] * 86400 + $diff[ 2 ] * 3600 + $diff[ 3 ] * 60 + $diff[ 4 ];
415 415
         //if($diff[0] != '-' && $diff != 0)
416 416
           //  throw new OptimiseException('timeslot time <= startTime');
417 417
         //TODO fix check
418 418
         //TODO check if diff makes sense
419 419
         //TODO check upper limit
420
-        return (int)(round($diff/self::TIME_SLOT_DURATION)+1); //TODO can round cause overlaps?
420
+        return (int) (round($diff / self::TIME_SLOT_DURATION) + 1); //TODO can round cause overlaps?
421 421
     }
422 422
 
423 423
     /**
@@ -427,6 +427,6 @@  discard block
 block discarded – undo
427 427
     private function toDateTime($timeslot)
428 428
     {
429 429
         $ret = clone $this->startTime;
430
-        return $ret->add(new \DateInterval('PT'.(($timeslot-1)*self::TIME_SLOT_DURATION).'S'));
430
+        return $ret->add(new \DateInterval('PT'.(($timeslot - 1) * self::TIME_SLOT_DURATION).'S'));
431 431
     }
432 432
 }
433 433
\ No newline at end of file
Please login to merge, or discard this patch.
app/Console/Commands/Optimise/OptimiseCommand.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 
63 63
         //TODO try...catch with destruct
64 64
         $companyId = $this->argument('companyId');
65
-        if(is_numeric($companyId))
65
+        if (is_numeric($companyId))
66 66
             $this->makeForeground(Company::findOrFail($companyId));
67 67
         else
68 68
             $this->syncAll();
@@ -71,15 +71,15 @@  discard block
 block discarded – undo
71 71
     private function syncAll()
72 72
     {
73 73
         $calendars = Caldav::all();
74
-        if($this->option('background')) {
74
+        if ($this->option('background')) {
75 75
             \Log::debug(self::BACKGROUND_MOD_MEX);
76 76
             $this->info(self::BACKGROUND_MOD_MEX);
77 77
             foreach ($calendars as $calendar)
78 78
                 $this->makeBackground($calendar);
79 79
             \Log::debug(self::BACKGROUND_COMPLETED_MEX);
80 80
             $this->info(self::BACKGROUND_COMPLETED_MEX);
81
-        }else
82
-            foreach($calendars as $calendar)
81
+        } else
82
+            foreach ($calendars as $calendar)
83 83
                 $this->makeForeground($calendar);
84 84
     }
85 85
 
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
     private function makeBackground(Company $company)
91 91
     {
92 92
         $event = $this->schedule->command('optimise:meetings '.$company->id)->withoutOverlapping();
93
-        if($event->isDue($this->laravel))
93
+        if ($event->isDue($this->laravel))
94 94
             $event->run($this->laravel);
95 95
     }
96 96
 
@@ -100,8 +100,8 @@  discard block
 block discarded – undo
100 100
      */
101 101
     private function makeForeground(Company $company)
102 102
     {
103
-        $this->info('Optimisation company '. $company->id.' started');
103
+        $this->info('Optimisation company '.$company->id.' started');
104 104
         (new Optimise($company))->optimise()->save();
105
-        $this->info('Optimisation '. $company->id.' completed');
105
+        $this->info('Optimisation '.$company->id.' completed');
106 106
     }
107 107
 }
Please login to merge, or discard this patch.
app/Console/Commands/Optimise/Solver.php 1 patch
Spacing   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
      */
114 114
     static private function checkGlpsol()
115 115
     {
116
-        if(!(`which glpsol`))
116
+        if (!(`which glpsol`))
117 117
             throw new OptimiseException('glpsol is not installed');
118 118
     }
119 119
 
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
      * @return bool
124 124
      */
125 125
     private static function delTree($dir) {
126
-        $files = array_diff(scandir($dir), array('.','..'));
126
+        $files = array_diff(scandir($dir), array('.', '..'));
127 127
         foreach ($files as $file) {
128 128
             (is_dir("$dir/$file")) ? delTree("$dir/$file") : unlink("$dir/$file");
129 129
         }
@@ -138,11 +138,11 @@  discard block
 block discarded – undo
138 138
     {
139 139
         $this->path = tempnam(sys_get_temp_dir(), 'OPT'); //TODO check the return in case of errors this return false on failure
140 140
         unlink($this->path); //remove file to create a dir
141
-        if(file_exists($this->path))
141
+        if (file_exists($this->path))
142 142
             throw new OptimiseException('problem during creation of tmp dir (the directory already exists)');
143
-        if(!@mkdir($this->path))
144
-            throw new OptimiseException('problem during creation of tmp dir (mkdir problem)');;
145
-        if(! is_dir($this->path))
143
+        if (!@mkdir($this->path))
144
+            throw new OptimiseException('problem during creation of tmp dir (mkdir problem)'); ;
145
+        if (!is_dir($this->path))
146 146
             throw new OptimiseException('problem during creation of tmp dir (it is not possible to create directory)');
147 147
     }
148 148
 
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
      */
224 224
     public function setTimeSlots($timeSlots)
225 225
     {
226
-        if(!is_int($timeSlots) || $timeSlots <=0)
226
+        if (!is_int($timeSlots) || $timeSlots <= 0)
227 227
             throw new OptimiseException('$timeSlots is not integer or it is not >0');
228 228
 
229 229
         $this->timeSlots = $timeSlots;
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
      */
246 246
     public function setMaxTimeSlots($maxTimeSlots)
247 247
     {
248
-        if(!is_int($maxTimeSlots) || $maxTimeSlots <=0)
248
+        if (!is_int($maxTimeSlots) || $maxTimeSlots <= 0)
249 249
             throw new OptimiseException('$maxTimeSlots is not integer or it is not >0');
250 250
 
251 251
         $this->maxTimeSlots = $maxTimeSlots;
@@ -268,13 +268,13 @@  discard block
 block discarded – undo
268 268
     public function setMeetingsAvailability($meetingsAvailability)
269 269
     {
270 270
         $meetings = array_keys($meetingsAvailability);
271
-        if(array_diff($meetings, $this->meetings))
271
+        if (array_diff($meetings, $this->meetings))
272 272
             throw new OptimiseException('meetings different from meetings set');
273
-        foreach($meetingsAvailability as $key=>$meetingsAvailabilityS) {
273
+        foreach ($meetingsAvailability as $key=>$meetingsAvailabilityS) {
274 274
             $timeSlots = array_keys($meetingsAvailabilityS);
275
-            if(count($timeSlots) != $this->timeSlots)
275
+            if (count($timeSlots) != $this->timeSlots)
276 276
                 throw new OptimiseException('timeSlots different from timeSlots set');
277
-            $meetingsAvailability[$key] = self::arrayPad($meetingsAvailabilityS, $this->timeSlots + $this->maxTimeSlots, 0);
277
+            $meetingsAvailability[ $key ] = self::arrayPad($meetingsAvailabilityS, $this->timeSlots + $this->maxTimeSlots, 0);
278 278
         }
279 279
 
280 280
         $this->meetingsAvailability = $meetingsAvailability;
@@ -297,13 +297,13 @@  discard block
 block discarded – undo
297 297
     public function setMeetingsDuration($meetingsDuration)
298 298
     {
299 299
         $meetings = array_keys($meetingsDuration);
300
-        if(array_diff($meetings, $this->meetings)) {
300
+        if (array_diff($meetings, $this->meetings)) {
301 301
             print "";
302 302
             throw new OptimiseException('meetings different from meetings set');
303 303
         }
304
-        foreach($meetingsDuration as $duration) {
304
+        foreach ($meetingsDuration as $duration) {
305 305
             $duration = (int) $duration; //TODO fix this (fix for optimise)
306
-            if(!is_int($duration) || $duration <=0)
306
+            if (!is_int($duration) || $duration <= 0)
307 307
                 throw new OptimiseException('duration is not integer or it is not >0');
308 308
         }
309 309
 
@@ -327,14 +327,14 @@  discard block
 block discarded – undo
327 327
     public function setUsersAvailability($usersAvailability)
328 328
     {
329 329
         $users = array_keys($usersAvailability);
330
-        if(array_diff($users, $this->users))
330
+        if (array_diff($users, $this->users))
331 331
             throw new OptimiseException('users different from users set');
332
-        foreach($usersAvailability as $key=>$usersAvailabilityS) {
332
+        foreach ($usersAvailability as $key=>$usersAvailabilityS) {
333 333
             $timeSlots = array_keys($usersAvailabilityS);
334
-            if(count($timeSlots) != $this->timeSlots)
334
+            if (count($timeSlots) != $this->timeSlots)
335 335
                 throw new OptimiseException('timeSlots different from timeSlots set');
336 336
 
337
-            $usersAvailability[$key] = self::arrayPad($usersAvailabilityS, $this->timeSlots + $this->maxTimeSlots, 0);
337
+            $usersAvailability[ $key ] = self::arrayPad($usersAvailabilityS, $this->timeSlots + $this->maxTimeSlots, 0);
338 338
         }
339 339
 
340 340
         $this->usersAvailability = $usersAvailability;
@@ -357,11 +357,11 @@  discard block
 block discarded – undo
357 357
     public function setUsersMeetings($usersMeetings)
358 358
     {
359 359
         $users = array_keys($usersMeetings);
360
-        if(array_diff($users, $this->users))
360
+        if (array_diff($users, $this->users))
361 361
             throw new OptimiseException('users different from users set');
362
-        foreach($usersMeetings as $usersMeetingsS) {
362
+        foreach ($usersMeetings as $usersMeetingsS) {
363 363
             $meetings = array_keys($usersMeetingsS);
364
-            if(array_diff($meetings, $this->meetings))
364
+            if (array_diff($meetings, $this->meetings))
365 365
                 throw new OptimiseException('meetings different from meetings set');
366 366
         }
367 367
 
@@ -424,13 +424,13 @@  discard block
 block discarded – undo
424 424
      */
425 425
     static private function writeCSVArrayNoKey($file, $data)
426 426
     {
427
-        $f = function ($fp, $data){
427
+        $f = function($fp, $data) {
428 428
             foreach ($data as $field) {
429
-                fputcsv($fp, [$field]);
429
+                fputcsv($fp, [ $field ]);
430 430
             }
431 431
         };
432 432
 
433
-        self::writeCSV($file, $data, ['i'], $f);
433
+        self::writeCSV($file, $data, [ 'i' ], $f);
434 434
     }
435 435
 
436 436
     /**
@@ -441,13 +441,13 @@  discard block
 block discarded – undo
441 441
      */
442 442
     static private function writeCSVArray($file, $data, $name)
443 443
     {
444
-        $f = function ($fp, $data){
444
+        $f = function($fp, $data) {
445 445
             foreach ($data as $key=>$field) {
446
-                fputcsv($fp, [$key, $field]);
446
+                fputcsv($fp, [ $key, $field ]);
447 447
             }
448 448
         };
449 449
 
450
-        self::writeCSV($file, $data, ['i', $name], $f);
450
+        self::writeCSV($file, $data, [ 'i', $name ], $f);
451 451
     }
452 452
 
453 453
     /**
@@ -458,14 +458,14 @@  discard block
 block discarded – undo
458 458
      */
459 459
     static private function writeCSVMatrix($file, $data, $name)
460 460
     {
461
-        $f = function ($fp, $data){
461
+        $f = function($fp, $data) {
462 462
             foreach ($data as $key=>$field) {
463 463
                 foreach ($field as $key2=>$field2)
464
-                    fputcsv($fp, [$key, $key2, $field2]);
464
+                    fputcsv($fp, [ $key, $key2, $field2 ]);
465 465
             }
466 466
         };
467 467
 
468
-        self::writeCSV($file, $data, ['i', 'j', $name], $f);
468
+        self::writeCSV($file, $data, [ 'i', 'j', $name ], $f);
469 469
     }
470 470
 
471 471
     /**
@@ -478,7 +478,7 @@  discard block
 block discarded – undo
478 478
     static private function writeCSV($file, $data, $heading, \Closure $writer)
479 479
     {
480 480
         $fp = @fopen($file, 'w');
481
-        if(!$fp)
481
+        if (!$fp)
482 482
             throw new OptimiseException('problem during creation of a file');
483 483
 
484 484
         fputcsv($fp, $heading);
@@ -498,8 +498,8 @@  discard block
 block discarded – undo
498 498
     {
499 499
         $this->writeData();
500 500
         $this->writeModelFile();
501
-        $event = $this->schedule->exec('glpsol --math '.$this->getModelPath())->sendOutputTo($this->getOutputPath())->after(function () { }); //this just to execute in foreground
502
-        if($event->isDue($this->laravel))
501
+        $event = $this->schedule->exec('glpsol --math '.$this->getModelPath())->sendOutputTo($this->getOutputPath())->after(function() { }); //this just to execute in foreground
502
+        if ($event->isDue($this->laravel))
503 503
             $event->run($this->laravel);
504 504
         //TODO catch glpsol errors
505 505
         return $this;
@@ -513,9 +513,9 @@  discard block
 block discarded – undo
513 513
         $strReplaceS = array('{USERS_PATH}', '{MEETINGS_PATH}', '{USER_AVAILABILITY_PATH}', '{MEETINGS_AVAILABILITY_PATH}', '{USER_MEETINGS_PATH}', '{MEETINGS_DURATION_PATH}', '{TIME_SLOTS}', '{MAX_TIME_SLOTS}', '{X_OUT_PATH}', '{Y_OUT_PATH}');
514 514
         $strReplaceR = array($this->getUsersPath(), $this->getMeetingsPath(), $this->getUsersAvailabilityPath(), $this->getMeetingsAvailabilityPath(), $this->getUsersMeetingsPath(), $this->getMeetingsDurationPath(), $this->timeSlots, $this->maxTimeSlots, $this->getXPath(), $this->getYPath());
515 515
         $f = @fopen($this->getModelPath(), "w");
516
-        if(!$f)
516
+        if (!$f)
517 517
             throw new OptimiseException('problem during creation of a file');
518
-        fwrite($f, str_replace($strReplaceS, $strReplaceR, file_get_contents(__DIR__ . "/model.stub")));
518
+        fwrite($f, str_replace($strReplaceS, $strReplaceR, file_get_contents(__DIR__."/model.stub")));
519 519
         fclose($f);
520 520
     }
521 521
 
@@ -543,7 +543,7 @@  discard block
 block discarded – undo
543 543
      */
544 544
     public function getOutput()
545 545
     {
546
-        if(!($data = file_get_contents($this->getOutputPath())))
546
+        if (!($data = file_get_contents($this->getOutputPath())))
547 547
             throw new OptimiseException('problems during reading the file');
548 548
         return $data;
549 549
     }
@@ -555,22 +555,22 @@  discard block
 block discarded – undo
555 555
      */
556 556
     static private function readCSVFile($file)
557 557
     {
558
-        if(!file_exists($file) || !filesize($file))
558
+        if (!file_exists($file) || !filesize($file))
559 559
             throw new OptimiseException('no results file');
560 560
 
561
-        $handle = @fopen($file,"r");
562
-        if(!$handle)
561
+        $handle = @fopen($file, "r");
562
+        if (!$handle)
563 563
             throw new OptimiseException('problems during reading the file');
564 564
 
565
-        $ret = [];
565
+        $ret = [ ];
566 566
         fgetcsv($handle); //skip head
567 567
         while (($data = fgetcsv($handle)) !== FALSE) {
568
-            if(count($data) != 3) {
568
+            if (count($data) != 3) {
569 569
                 fclose($handle);
570 570
                 throw new OptimiseException('problems during parsing the file');
571 571
             }
572 572
 
573
-            $ret[$data[0]][$data[1]] = $data[2];
573
+            $ret[ $data[ 0 ] ][ $data[ 1 ] ] = $data[ 2 ];
574 574
         }
575 575
 
576 576
         fclose($handle);
@@ -677,8 +677,8 @@  discard block
 block discarded – undo
677 677
      */
678 678
     private function checkData()
679 679
     {
680
-        $this->checkArrayProprieties(['users', 'meetings', 'meetingsAvailability', 'meetingsDuration', 'usersAvailability', 'usersMeetings']);
681
-        $this->checkIntProprieties(['timeSlots', 'maxTimeSlots']);
680
+        $this->checkArrayProprieties([ 'users', 'meetings', 'meetingsAvailability', 'meetingsDuration', 'usersAvailability', 'usersMeetings' ]);
681
+        $this->checkIntProprieties([ 'timeSlots', 'maxTimeSlots' ]);
682 682
     }
683 683
 
684 684
     /**
@@ -687,8 +687,8 @@  discard block
 block discarded – undo
687 687
      */
688 688
     private function checkArrayProprieties($proprieties)
689 689
     {
690
-        foreach($proprieties as $propriety)
691
-            if(count($this->$propriety)==0)
690
+        foreach ($proprieties as $propriety)
691
+            if (count($this->$propriety) == 0)
692 692
                 throw new OptimiseException($propriety.' is not set correctly');
693 693
     }
694 694
 
@@ -698,8 +698,8 @@  discard block
 block discarded – undo
698 698
      */
699 699
     private function checkIntProprieties($proprieties)
700 700
     {
701
-        foreach($proprieties as $propriety)
702
-            if(!is_int($this->$propriety) || $this->$propriety <= 0)
701
+        foreach ($proprieties as $propriety)
702
+            if (!is_int($this->$propriety) || $this->$propriety <= 0)
703 703
                 throw new OptimiseException($propriety.' is not set correctly');
704 704
     }
705 705
 
@@ -712,8 +712,8 @@  discard block
 block discarded – undo
712 712
     static private function arrayPad(array $array, $len, $pad)
713 713
     {
714 714
         $len = $len - count($array);
715
-        for($i = 0; $i<$len; $i++)
716
-            $array[] = $pad;
715
+        for ($i = 0; $i < $len; $i++)
716
+            $array[ ] = $pad;
717 717
         return $array;
718 718
     }
719 719
 }
720 720
\ No newline at end of file
Please login to merge, or discard this patch.
app/Company.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -48,14 +48,14 @@  discard block
 block discarded – undo
48 48
      *
49 49
      * @var array
50 50
      */
51
-    protected $fillable = ['name', 'email', 'password'];
51
+    protected $fillable = [ 'name', 'email', 'password' ];
52 52
 
53 53
     /**
54 54
      * The attributes excluded from the model's JSON form.
55 55
      *
56 56
      * @var array
57 57
      */
58
-    protected $hidden = ['password', 'remember_token'];
58
+    protected $hidden = [ 'password', 'remember_token' ];
59 59
 
60 60
     /**
61 61
      * @return \Illuminate\Database\Eloquent\Relations\HasMany
@@ -120,8 +120,8 @@  discard block
 block discarded – undo
120 120
             ->where('calendars.enabled', '=', '1')
121 121
             ->where('timeslots.time_start', '>=', $from)
122 122
             ->where('timeslots.time_end', '<=', $to)
123
-            ->where('employees.company_id','=', $this->id)
124
-            ->select('employees.id','timeslots.time_start','timeslots.time_end')
123
+            ->where('employees.company_id', '=', $this->id)
124
+            ->select('employees.id', 'timeslots.time_start', 'timeslots.time_end')
125 125
             ->get();
126 126
     }
127 127
 
@@ -137,9 +137,9 @@  discard block
 block discarded – undo
137 137
             ->join('meeting_timeslots', 'meetings.id', '=', 'meeting_timeslots.meeting_id')
138 138
             ->where('meeting_timeslots.time_start', '>=', $from)
139 139
             ->where('meeting_timeslots.time_end', '<=', $to)
140
-            ->where('groups.company_id','=', $this->id)
140
+            ->where('groups.company_id', '=', $this->id)
141 141
             //->where('meetings.start_time','=', 'NULL')
142
-            ->select('meetings.id', 'meetings.duration','meeting_timeslots.time_start','meeting_timeslots.time_end')
142
+            ->select('meetings.id', 'meetings.duration', 'meeting_timeslots.time_start', 'meeting_timeslots.time_end')
143 143
             ->get();
144 144
     }
145 145
 
@@ -151,8 +151,8 @@  discard block
 block discarded – undo
151 151
             ->join('employees', 'employee_group.employee_id', '=', 'employees.id')
152 152
             ->whereIn('employees.id', $users)
153 153
             ->whereIn('meetings.id', $meetings)
154
-            ->where('groups.company_id','=', $this->id) //this is not needed
155
-            ->where('employees.company_id','=', $this->id) //this is not needed
154
+            ->where('groups.company_id', '=', $this->id) //this is not needed
155
+            ->where('employees.company_id', '=', $this->id) //this is not needed
156 156
             ->select('employees.id as employee_id', 'meetings.id as meeting_id')
157 157
             ->get();
158 158
     }
Please login to merge, or discard this patch.