@@ -51,8 +51,9 @@ |
||
| 51 | 51 | |
| 52 | 52 | public function getPlannerNameAttribute() |
| 53 | 53 | { |
| 54 | - if(is_object($this->planner) && $this->planner->exists) |
|
| 55 | - return $this->planner->name; |
|
| 54 | + if(is_object($this->planner) && $this->planner->exists) { |
|
| 55 | + return $this->planner->name; |
|
| 56 | + } |
|
| 56 | 57 | } |
| 57 | 58 | |
| 58 | 59 | /** |
@@ -71,8 +71,9 @@ |
||
| 71 | 71 | $employee = Employee::findOrFail($employeeId); |
| 72 | 72 | $this->authorize($employee); |
| 73 | 73 | $group = Group::findOrFail($groupId); |
| 74 | - if(!$employee->belongsToGroup($group)) |
|
| 75 | - return Response::json(['error' => 'employId <> groupId'],404); |
|
| 74 | + if(!$employee->belongsToGroup($group)) { |
|
| 75 | + return Response::json(['error' => 'employId <> groupId'],404); |
|
| 76 | + } |
|
| 76 | 77 | $employee->groups()->detach($groupId); |
| 77 | 78 | return $group->employees; |
| 78 | 79 | } |
@@ -53,8 +53,9 @@ discard block |
||
| 53 | 53 | // |
| 54 | 54 | $company = \Auth::user(); |
| 55 | 55 | $input = $request->all(); |
| 56 | - if(isset($input['password'])) |
|
| 57 | - $input['password'] = bcrypt($input['password']); |
|
| 56 | + if(isset($input['password'])) { |
|
| 57 | + $input['password'] = bcrypt($input['password']); |
|
| 58 | + } |
|
| 58 | 59 | $employee = $company->employees()->create($input); |
| 59 | 60 | return $employee; |
| 60 | 61 | } |
@@ -86,8 +87,9 @@ discard block |
||
| 86 | 87 | $employee = Employee::findOrFail($id); |
| 87 | 88 | $this->authorize($employee); |
| 88 | 89 | $input = $request->all(); |
| 89 | - if(isset($input['password'])) |
|
| 90 | - $input['password'] = bcrypt($input['password']); |
|
| 90 | + if(isset($input['password'])) { |
|
| 91 | + $input['password'] = bcrypt($input['password']); |
|
| 92 | + } |
|
| 91 | 93 | $employee->update($input); |
| 92 | 94 | return $employee; |
| 93 | 95 | } |
@@ -53,10 +53,11 @@ discard block |
||
| 53 | 53 | { |
| 54 | 54 | // |
| 55 | 55 | $calendarId = $this->argument('calendarId'); |
| 56 | - if(is_numeric($calendarId)) |
|
| 57 | - $this->makeForeground(Caldav::findOrFail($calendarId)); |
|
| 58 | - else |
|
| 59 | - $this->syncAll(); |
|
| 56 | + if(is_numeric($calendarId)) { |
|
| 57 | + $this->makeForeground(Caldav::findOrFail($calendarId)); |
|
| 58 | + } else { |
|
| 59 | + $this->syncAll(); |
|
| 60 | + } |
|
| 60 | 61 | } |
| 61 | 62 | |
| 62 | 63 | private function syncAll() |
@@ -65,13 +66,15 @@ discard block |
||
| 65 | 66 | if($this->option('background')) { |
| 66 | 67 | \Log::debug(self::BACKGROUND_MOD_MEX); |
| 67 | 68 | $this->info(self::BACKGROUND_MOD_MEX); |
| 68 | - foreach ($calendars as $calendar) |
|
| 69 | - $this->makeBackground($calendar); |
|
| 69 | + foreach ($calendars as $calendar) { |
|
| 70 | + $this->makeBackground($calendar); |
|
| 71 | + } |
|
| 70 | 72 | \Log::debug(self::BACKGROUND_COMPLETED_MEX); |
| 71 | 73 | $this->info(self::BACKGROUND_COMPLETED_MEX); |
| 72 | - }else |
|
| 73 | - foreach($calendars as $calendar) |
|
| 74 | + } else { |
|
| 75 | + foreach($calendars as $calendar) |
|
| 74 | 76 | $this->makeForeground($calendar); |
| 77 | + } |
|
| 75 | 78 | } |
| 76 | 79 | |
| 77 | 80 | /** |
@@ -81,8 +84,9 @@ discard block |
||
| 81 | 84 | private function makeBackground(Caldav $calendar) |
| 82 | 85 | { |
| 83 | 86 | $event = $this->schedule->command('sync:caldav '.$calendar->calendar_id)->withoutOverlapping(); |
| 84 | - if($event->isDue($this->laravel)) |
|
| 85 | - $event->run($this->laravel); |
|
| 87 | + if($event->isDue($this->laravel)) { |
|
| 88 | + $event->run($this->laravel); |
|
| 89 | + } |
|
| 86 | 90 | } |
| 87 | 91 | |
| 88 | 92 | /** |
@@ -66,8 +66,9 @@ discard block |
||
| 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 | 72 | $calendar->caldav()->create($input); |
| 72 | 73 | //TODO test |
| 73 | 74 | //TODO validator |
@@ -107,15 +108,17 @@ discard block |
||
| 107 | 108 | if($caldav){ |
| 108 | 109 | $this->validateCaldav($request); |
| 109 | 110 | } |
| 110 | - if(isset($input['password'])) |
|
| 111 | - $input['password'] = \Crypt::encrypt($input['password']); |
|
| 111 | + if(isset($input['password'])) { |
|
| 112 | + $input['password'] = \Crypt::encrypt($input['password']); |
|
| 113 | + } |
|
| 112 | 114 | $calendar->update($input); |
| 113 | 115 | //TODO test |
| 114 | 116 | //TODO validator |
| 115 | 117 | //TODO check if caldav exists? |
| 116 | 118 | |
| 117 | - if($caldav) |
|
| 118 | - $caldav->update($input); |
|
| 119 | + if($caldav) { |
|
| 120 | + $caldav->update($input); |
|
| 121 | + } |
|
| 119 | 122 | return $calendar; |
| 120 | 123 | } |
| 121 | 124 | |
@@ -148,7 +151,7 @@ discard block |
||
| 148 | 151 | $caldavClient->connect($request->input('url'), $request->input('username'), $request->input('password')); |
| 149 | 152 | $calendars = $caldavClient->findCalendars(); |
| 150 | 153 | return array_keys($calendars); |
| 151 | - }catch (\it\thecsea\caldav_client_adapter\CaldavException $e) |
|
| 154 | + } catch (\it\thecsea\caldav_client_adapter\CaldavException $e) |
|
| 152 | 155 | { |
| 153 | 156 | return Response::json(['error' => $e->getMessage()],422); |
| 154 | 157 | } |
@@ -91,11 +91,11 @@ discard block |
||
| 91 | 91 | try |
| 92 | 92 | { |
| 93 | 93 | $events = $this->getEvents(); |
| 94 | - }catch (\it\thecsea\caldav_client_adapter\CaldavException $e) |
|
| 94 | + } catch (\it\thecsea\caldav_client_adapter\CaldavException $e) |
|
| 95 | 95 | { |
| 96 | 96 | \Event::fire(new ErrorEvent($this->calendar, $e->getMessage())); |
| 97 | 97 | return ; |
| 98 | - }catch(\Illuminate\Contracts\Encryption\DecryptException $e){ |
|
| 98 | + } catch(\Illuminate\Contracts\Encryption\DecryptException $e){ |
|
| 99 | 99 | \Event::fire(new ErrorEvent($this->calendar, $e->getMessage())); |
| 100 | 100 | return ; |
| 101 | 101 | } |
@@ -110,10 +110,11 @@ discard block |
||
| 110 | 110 | |
| 111 | 111 | //insert new timeslots |
| 112 | 112 | foreach($events as $event){ |
| 113 | - if(!($event = $this->parseEvent($event))) |
|
| 114 | - \Event::fire(new ErrorEvent($this->calendar, 'problem during the parsing an event')); |
|
| 115 | - else |
|
| 116 | - $calendarMain->timeslots()->create($event); |
|
| 113 | + if(!($event = $this->parseEvent($event))) { |
|
| 114 | + \Event::fire(new ErrorEvent($this->calendar, 'problem during the parsing an event')); |
|
| 115 | + } else { |
|
| 116 | + $calendarMain->timeslots()->create($event); |
|
| 117 | + } |
|
| 117 | 118 | } |
| 118 | 119 | \Event::fire(new OkEvent($this->calendar)); |
| 119 | 120 | } |
@@ -126,17 +127,20 @@ discard block |
||
| 126 | 127 | { |
| 127 | 128 | $pattern = "/^((DTSTART;)|(DTEND;))(.*)\$/m"; |
| 128 | 129 | if(preg_match_all($pattern, $event->getData(), $matches)){ |
| 129 | - if(!isset($matches[4]) || count($matches[4]) != 2) |
|
| 130 | - return null; |
|
| 130 | + if(!isset($matches[4]) || count($matches[4]) != 2) { |
|
| 131 | + return null; |
|
| 132 | + } |
|
| 131 | 133 | $ret = []; |
| 132 | - if($tmp = $this->parseDate($matches[4][0])) |
|
| 133 | - $ret['time_start'] = $tmp; |
|
| 134 | - else |
|
| 135 | - return null; |
|
| 136 | - if($tmp = $this->parseDate($matches[4][1])) |
|
| 137 | - $ret['time_end'] = $tmp; |
|
| 138 | - else |
|
| 139 | - return null; |
|
| 134 | + if($tmp = $this->parseDate($matches[4][0])) { |
|
| 135 | + $ret['time_start'] = $tmp; |
|
| 136 | + } else { |
|
| 137 | + return null; |
|
| 138 | + } |
|
| 139 | + if($tmp = $this->parseDate($matches[4][1])) { |
|
| 140 | + $ret['time_end'] = $tmp; |
|
| 141 | + } else { |
|
| 142 | + return null; |
|
| 143 | + } |
|
| 140 | 144 | return $ret; |
| 141 | 145 | } |
| 142 | 146 | return null; |
@@ -153,7 +157,7 @@ discard block |
||
| 153 | 157 | if($matches[1][0] == 'TZID=') |
| 154 | 158 | { |
| 155 | 159 | return \DateTime::createFromFormat('Ymd\THis', $matches[5][0], new \DateTimeZone($matches[4][0])); |
| 156 | - }else if($matches[1][0] == 'VALUE=' && $matches[4][0] == 'DATE') |
|
| 160 | + } else if($matches[1][0] == 'VALUE=' && $matches[4][0] == 'DATE') |
|
| 157 | 161 | { |
| 158 | 162 | return \DateTime::createFromFormat('Ymd\THis', $matches[5][0].'T000000'); |
| 159 | 163 | } |
@@ -62,10 +62,11 @@ discard block |
||
| 62 | 62 | |
| 63 | 63 | //TODO try...catch with destruct |
| 64 | 64 | $companyId = $this->argument('companyId'); |
| 65 | - if(is_numeric($companyId)) |
|
| 66 | - $this->makeForeground(Company::findOrFail($companyId)); |
|
| 67 | - else |
|
| 68 | - $this->syncAll(); |
|
| 65 | + if(is_numeric($companyId)) { |
|
| 66 | + $this->makeForeground(Company::findOrFail($companyId)); |
|
| 67 | + } else { |
|
| 68 | + $this->syncAll(); |
|
| 69 | + } |
|
| 69 | 70 | } |
| 70 | 71 | |
| 71 | 72 | private function syncAll() |
@@ -74,13 +75,15 @@ discard block |
||
| 74 | 75 | if($this->option('background')) { |
| 75 | 76 | \Log::debug(self::BACKGROUND_MOD_MEX); |
| 76 | 77 | $this->info(self::BACKGROUND_MOD_MEX); |
| 77 | - foreach ($calendars as $calendar) |
|
| 78 | - $this->makeBackground($calendar); |
|
| 78 | + foreach ($calendars as $calendar) { |
|
| 79 | + $this->makeBackground($calendar); |
|
| 80 | + } |
|
| 79 | 81 | \Log::debug(self::BACKGROUND_COMPLETED_MEX); |
| 80 | 82 | $this->info(self::BACKGROUND_COMPLETED_MEX); |
| 81 | - }else |
|
| 82 | - foreach($calendars as $calendar) |
|
| 83 | + } else { |
|
| 84 | + foreach($calendars as $calendar) |
|
| 83 | 85 | $this->makeForeground($calendar); |
| 86 | + } |
|
| 84 | 87 | } |
| 85 | 88 | |
| 86 | 89 | /** |
@@ -90,8 +93,9 @@ discard block |
||
| 90 | 93 | private function makeBackground(Company $company) |
| 91 | 94 | { |
| 92 | 95 | $event = $this->schedule->command('optimise:meetings '.$company->id)->withoutOverlapping(); |
| 93 | - if($event->isDue($this->laravel)) |
|
| 94 | - $event->run($this->laravel); |
|
| 96 | + if($event->isDue($this->laravel)) { |
|
| 97 | + $event->run($this->laravel); |
|
| 98 | + } |
|
| 95 | 99 | } |
| 96 | 100 | |
| 97 | 101 | /** |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | $solver = $this->setData($solver); |
| 157 | 157 | $solver = $solver->solve(); |
| 158 | 158 | $this->solver = $solver; |
| 159 | - }catch(\Exception $e) |
|
| 159 | + } catch(\Exception $e) |
|
| 160 | 160 | { |
| 161 | 161 | \Event::fire(new ErrorEvent($this->company, $e->getMessage())); |
| 162 | 162 | throw new OptimiseException('Optimising error', 0, $e); |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | try { |
| 181 | 181 | $this->saveMeetings($this->solver); |
| 182 | 182 | $this->saveEmployeesMeetings($this->solver); |
| 183 | - }catch(\Exception $e) |
|
| 183 | + } catch(\Exception $e) |
|
| 184 | 184 | { |
| 185 | 185 | \Event::fire(new ErrorEvent($this->company, $e->getMessage())); |
| 186 | 186 | throw new OptimiseException('Optimising error', 0, $e); |
@@ -327,7 +327,7 @@ discard block |
||
| 327 | 327 | foreach($meetings as $meeting){ |
| 328 | 328 | if($usersMeetingsTmp->contains('meeting_id', $meeting)){ |
| 329 | 329 | $ret[$user][$meeting] = 1; |
| 330 | - }else{ |
|
| 330 | + } else{ |
|
| 331 | 331 | $ret[$user][$meeting] = 0; |
| 332 | 332 | } |
| 333 | 333 | } |
@@ -373,8 +373,9 @@ discard block |
||
| 373 | 373 | static private function fillTimeSlots(array $array, $id, \Illuminate\Support\Collection $timeSlots, $fill = '0') |
| 374 | 374 | { |
| 375 | 375 | foreach($timeSlots as $timeSlot) { |
| 376 | - if(!isset($array[$id])) |
|
| 377 | - $array[$id] = []; |
|
| 376 | + if(!isset($array[$id])) { |
|
| 377 | + $array[$id] = []; |
|
| 378 | + } |
|
| 378 | 379 | $array[$id] = self::arrayPadInterval($array[$id], $timeSlot->time_start, $timeSlot->time_end, $fill); |
| 379 | 380 | } |
| 380 | 381 | return $array; |
@@ -389,8 +390,9 @@ discard block |
||
| 389 | 390 | static private function fillRow(array $array, $id, $until, $fill = '0') |
| 390 | 391 | { |
| 391 | 392 | for($i = 1; $i <= $until; $i++){ |
| 392 | - if(!isset($array[$id][$i])) |
|
| 393 | - $array[$id][$i] = $fill; |
|
| 393 | + if(!isset($array[$id][$i])) { |
|
| 394 | + $array[$id][$i] = $fill; |
|
| 395 | + } |
|
| 394 | 396 | } |
| 395 | 397 | |
| 396 | 398 | return $array; |
@@ -405,8 +407,9 @@ discard block |
||
| 405 | 407 | */ |
| 406 | 408 | static private function arrayPadInterval(array $array, $from, $to, $pad = '0') |
| 407 | 409 | { |
| 408 | - for($i = $from; $i<$to; $i++) |
|
| 409 | - $array[$i] = $pad; |
|
| 410 | + for($i = $from; $i<$to; $i++) { |
|
| 411 | + $array[$i] = $pad; |
|
| 412 | + } |
|
| 410 | 413 | return $array; |
| 411 | 414 | } |
| 412 | 415 | |
@@ -112,8 +112,9 @@ discard block |
||
| 112 | 112 | */ |
| 113 | 113 | static private function checkGlpsol() |
| 114 | 114 | { |
| 115 | - if(!(`which glpsol`)) |
|
| 116 | - throw new OptimiseException('glpsol is not installed'); |
|
| 115 | + if(!(`which glpsol`)) { |
|
| 116 | + throw new OptimiseException('glpsol is not installed'); |
|
| 117 | + } |
|
| 117 | 118 | } |
| 118 | 119 | |
| 119 | 120 | /** |
@@ -193,8 +194,9 @@ discard block |
||
| 193 | 194 | */ |
| 194 | 195 | public function setTimeSlots($timeSlots) |
| 195 | 196 | { |
| 196 | - if(!is_int($timeSlots) || $timeSlots <=0) |
|
| 197 | - throw new OptimiseException('$timeSlots is not integer or it is not >0'); |
|
| 197 | + if(!is_int($timeSlots) || $timeSlots <=0) { |
|
| 198 | + throw new OptimiseException('$timeSlots is not integer or it is not >0'); |
|
| 199 | + } |
|
| 198 | 200 | |
| 199 | 201 | $this->timeSlots = $timeSlots; |
| 200 | 202 | return $this; |
@@ -215,8 +217,9 @@ discard block |
||
| 215 | 217 | */ |
| 216 | 218 | public function setMaxTimeSlots($maxTimeSlots) |
| 217 | 219 | { |
| 218 | - if(!is_int($maxTimeSlots) || $maxTimeSlots <=0) |
|
| 219 | - throw new OptimiseException('$maxTimeSlots is not integer or it is not >0'); |
|
| 220 | + if(!is_int($maxTimeSlots) || $maxTimeSlots <=0) { |
|
| 221 | + throw new OptimiseException('$maxTimeSlots is not integer or it is not >0'); |
|
| 222 | + } |
|
| 220 | 223 | |
| 221 | 224 | $this->maxTimeSlots = $maxTimeSlots; |
| 222 | 225 | return $this; |
@@ -238,12 +241,14 @@ discard block |
||
| 238 | 241 | public function setMeetingsAvailability($meetingsAvailability) |
| 239 | 242 | { |
| 240 | 243 | $meetings = array_keys($meetingsAvailability); |
| 241 | - if(array_diff($meetings, $this->meetings)) |
|
| 242 | - throw new OptimiseException('meetings different from meetings set'); |
|
| 244 | + if(array_diff($meetings, $this->meetings)) { |
|
| 245 | + throw new OptimiseException('meetings different from meetings set'); |
|
| 246 | + } |
|
| 243 | 247 | foreach($meetingsAvailability as $key=>$meetingsAvailabilityS) { |
| 244 | 248 | $timeSlots = array_keys($meetingsAvailabilityS); |
| 245 | - if(count($timeSlots) != $this->timeSlots) |
|
| 246 | - throw new OptimiseException('timeSlots different from timeSlots set'); |
|
| 249 | + if(count($timeSlots) != $this->timeSlots) { |
|
| 250 | + throw new OptimiseException('timeSlots different from timeSlots set'); |
|
| 251 | + } |
|
| 247 | 252 | $meetingsAvailability[$key] = self::arrayPad($meetingsAvailabilityS, $this->timeSlots + $this->maxTimeSlots, 0); |
| 248 | 253 | } |
| 249 | 254 | |
@@ -273,8 +278,9 @@ discard block |
||
| 273 | 278 | } |
| 274 | 279 | foreach($meetingsDuration as $duration) { |
| 275 | 280 | $duration = (int) $duration; //TODO fix this (fix for optimise) |
| 276 | - if(!is_int($duration) || $duration <=0) |
|
| 277 | - throw new OptimiseException('duration is not integer or it is not >0'); |
|
| 281 | + if(!is_int($duration) || $duration <=0) { |
|
| 282 | + throw new OptimiseException('duration is not integer or it is not >0'); |
|
| 283 | + } |
|
| 278 | 284 | } |
| 279 | 285 | |
| 280 | 286 | $this->meetingsDuration = $meetingsDuration; |
@@ -297,12 +303,14 @@ discard block |
||
| 297 | 303 | public function setUsersAvailability($usersAvailability) |
| 298 | 304 | { |
| 299 | 305 | $users = array_keys($usersAvailability); |
| 300 | - if(array_diff($users, $this->users)) |
|
| 301 | - throw new OptimiseException('users different from users set'); |
|
| 306 | + if(array_diff($users, $this->users)) { |
|
| 307 | + throw new OptimiseException('users different from users set'); |
|
| 308 | + } |
|
| 302 | 309 | foreach($usersAvailability as $key=>$usersAvailabilityS) { |
| 303 | 310 | $timeSlots = array_keys($usersAvailabilityS); |
| 304 | - if(count($timeSlots) != $this->timeSlots) |
|
| 305 | - throw new OptimiseException('timeSlots different from timeSlots set'); |
|
| 311 | + if(count($timeSlots) != $this->timeSlots) { |
|
| 312 | + throw new OptimiseException('timeSlots different from timeSlots set'); |
|
| 313 | + } |
|
| 306 | 314 | |
| 307 | 315 | $usersAvailability[$key] = self::arrayPad($usersAvailabilityS, $this->timeSlots + $this->maxTimeSlots, 0); |
| 308 | 316 | } |
@@ -327,12 +335,14 @@ discard block |
||
| 327 | 335 | public function setUsersMeetings($usersMeetings) |
| 328 | 336 | { |
| 329 | 337 | $users = array_keys($usersMeetings); |
| 330 | - if(array_diff($users, $this->users)) |
|
| 331 | - throw new OptimiseException('users different from users set'); |
|
| 338 | + if(array_diff($users, $this->users)) { |
|
| 339 | + throw new OptimiseException('users different from users set'); |
|
| 340 | + } |
|
| 332 | 341 | foreach($usersMeetings as $usersMeetingsS) { |
| 333 | 342 | $meetings = array_keys($usersMeetingsS); |
| 334 | - if(array_diff($meetings, $this->meetings)) |
|
| 335 | - throw new OptimiseException('meetings different from meetings set'); |
|
| 343 | + if(array_diff($meetings, $this->meetings)) { |
|
| 344 | + throw new OptimiseException('meetings different from meetings set'); |
|
| 345 | + } |
|
| 336 | 346 | } |
| 337 | 347 | |
| 338 | 348 | $this->usersMeetings = $usersMeetings; |
@@ -430,8 +440,9 @@ discard block |
||
| 430 | 440 | { |
| 431 | 441 | $f = function ($fp, $data){ |
| 432 | 442 | foreach ($data as $key=>$field) { |
| 433 | - foreach ($field as $key2=>$field2) |
|
| 434 | - fputcsv($fp, [$key, $key2, $field2]); |
|
| 443 | + foreach ($field as $key2=>$field2) { |
|
| 444 | + fputcsv($fp, [$key, $key2, $field2]); |
|
| 445 | + } |
|
| 435 | 446 | } |
| 436 | 447 | }; |
| 437 | 448 | |
@@ -448,8 +459,9 @@ discard block |
||
| 448 | 459 | static private function writeCSV($file, $data, $heading, \Closure $writer) |
| 449 | 460 | { |
| 450 | 461 | $fp = @fopen($file, 'w'); |
| 451 | - if(!$fp) |
|
| 452 | - throw new OptimiseException('problem during creation of a file'); |
|
| 462 | + if(!$fp) { |
|
| 463 | + throw new OptimiseException('problem during creation of a file'); |
|
| 464 | + } |
|
| 453 | 465 | |
| 454 | 466 | fputcsv($fp, $heading); |
| 455 | 467 | |
@@ -469,8 +481,9 @@ discard block |
||
| 469 | 481 | $this->writeData(); |
| 470 | 482 | $this->writeModelFile(); |
| 471 | 483 | $event = $this->schedule->exec('glpsol --math '.$this->path->getModelPath())->sendOutputTo($this->path->getOutputPath())->after(function () { }); //this just to execute in foreground |
| 472 | - if($event->isDue($this->laravel)) |
|
| 473 | - $event->run($this->laravel); |
|
| 484 | + if($event->isDue($this->laravel)) { |
|
| 485 | + $event->run($this->laravel); |
|
| 486 | + } |
|
| 474 | 487 | //TODO catch glpsol errors |
| 475 | 488 | return $this; |
| 476 | 489 | } |
@@ -483,8 +496,9 @@ discard block |
||
| 483 | 496 | $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}'); |
| 484 | 497 | $strReplaceR = array($this->path->getUsersPath(), $this->path->getMeetingsPath(), $this->path->getUsersAvailabilityPath(), $this->path->getMeetingsAvailabilityPath(), $this->path->getUsersMeetingsPath(), $this->path->getMeetingsDurationPath(), $this->timeSlots, $this->maxTimeSlots, $this->path->getXPath(), $this->path->getYPath()); |
| 485 | 498 | $f = @fopen($this->path->getModelPath(), "w"); |
| 486 | - if(!$f) |
|
| 487 | - throw new OptimiseException('problem during creation of a file'); |
|
| 499 | + if(!$f) { |
|
| 500 | + throw new OptimiseException('problem during creation of a file'); |
|
| 501 | + } |
|
| 488 | 502 | fwrite($f, str_replace($strReplaceS, $strReplaceR, file_get_contents(__DIR__ . "/model.stub"))); |
| 489 | 503 | fclose($f); |
| 490 | 504 | } |
@@ -513,8 +527,9 @@ discard block |
||
| 513 | 527 | */ |
| 514 | 528 | public function getOutput() |
| 515 | 529 | { |
| 516 | - if(!($data = file_get_contents($this->path->getOutputPath()))) |
|
| 517 | - throw new OptimiseException('problems during reading the file'); |
|
| 530 | + if(!($data = file_get_contents($this->path->getOutputPath()))) { |
|
| 531 | + throw new OptimiseException('problems during reading the file'); |
|
| 532 | + } |
|
| 518 | 533 | return $data; |
| 519 | 534 | } |
| 520 | 535 | |
@@ -525,12 +540,14 @@ discard block |
||
| 525 | 540 | */ |
| 526 | 541 | static private function readCSVFile($file) |
| 527 | 542 | { |
| 528 | - if(!file_exists($file) || !filesize($file)) |
|
| 529 | - throw new OptimiseException('no results file'); |
|
| 543 | + if(!file_exists($file) || !filesize($file)) { |
|
| 544 | + throw new OptimiseException('no results file'); |
|
| 545 | + } |
|
| 530 | 546 | |
| 531 | 547 | $handle = @fopen($file,"r"); |
| 532 | - if(!$handle) |
|
| 533 | - throw new OptimiseException('problems during reading the file'); |
|
| 548 | + if(!$handle) { |
|
| 549 | + throw new OptimiseException('problems during reading the file'); |
|
| 550 | + } |
|
| 534 | 551 | |
| 535 | 552 | $ret = []; |
| 536 | 553 | fgetcsv($handle); //skip head |
@@ -577,9 +594,10 @@ discard block |
||
| 577 | 594 | */ |
| 578 | 595 | private function checkArrayProprieties($proprieties) |
| 579 | 596 | { |
| 580 | - foreach($proprieties as $propriety) |
|
| 581 | - if(count($this->$propriety)==0) |
|
| 597 | + foreach($proprieties as $propriety) { |
|
| 598 | + if(count($this->$propriety)==0) |
|
| 582 | 599 | throw new OptimiseException($propriety.' is not set correctly'); |
| 600 | + } |
|
| 583 | 601 | } |
| 584 | 602 | |
| 585 | 603 | /** |
@@ -588,9 +606,10 @@ discard block |
||
| 588 | 606 | */ |
| 589 | 607 | private function checkIntProprieties($proprieties) |
| 590 | 608 | { |
| 591 | - foreach($proprieties as $propriety) |
|
| 592 | - if(!is_int($this->$propriety) || $this->$propriety <= 0) |
|
| 609 | + foreach($proprieties as $propriety) { |
|
| 610 | + if(!is_int($this->$propriety) || $this->$propriety <= 0) |
|
| 593 | 611 | throw new OptimiseException($propriety.' is not set correctly'); |
| 612 | + } |
|
| 594 | 613 | } |
| 595 | 614 | |
| 596 | 615 | /** |
@@ -602,8 +621,9 @@ discard block |
||
| 602 | 621 | static private function arrayPad(array $array, $len, $pad) |
| 603 | 622 | { |
| 604 | 623 | $len = $len - count($array); |
| 605 | - for($i = 0; $i<$len; $i++) |
|
| 606 | - $array[] = $pad; |
|
| 624 | + for($i = 0; $i<$len; $i++) { |
|
| 625 | + $array[] = $pad; |
|
| 626 | + } |
|
| 607 | 627 | return $array; |
| 608 | 628 | } |
| 609 | 629 | } |
| 610 | 630 | \ No newline at end of file |