Completed
Pull Request — master (#28)
by claudio
07:42 queued 01:16
created
app/PolicyCheckable.php 1 patch
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -1,21 +1,21 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Created by PhpStorm.
4
- * User: Claudio Cardinale <[email protected]>
5
- * Date: 24/11/15
6
- * Time: 21.58
7
- * This program is free software; you can redistribute it and/or
8
- * modify it under the terms of the GNU General Public License
9
- * as published by the Free Software Foundation; either version 2
10
- * of the License, or (at your option) any later version.
11
- * This program is distributed in the hope that it will be useful,
12
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
- * GNU General Public License for more details.
15
- * You should have received a copy of the GNU General Public License
16
- * along with this program; if not, write to the Free Software
17
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
18
- */
3
+     * Created by PhpStorm.
4
+     * User: Claudio Cardinale <[email protected]>
5
+     * Date: 24/11/15
6
+     * Time: 21.58
7
+     * This program is free software; you can redistribute it and/or
8
+     * modify it under the terms of the GNU General Public License
9
+     * as published by the Free Software Foundation; either version 2
10
+     * of the License, or (at your option) any later version.
11
+     * This program is distributed in the hope that it will be useful,
12
+     * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
+     * GNU General Public License for more details.
15
+     * You should have received a copy of the GNU General Public License
16
+     * along with this program; if not, write to the Free Software
17
+     * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
18
+     */
19 19
 
20 20
 namespace plunner;
21 21
 
Please login to merge, or discard this patch.
app/Group.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -51,8 +51,9 @@
 block discarded – undo
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
     /**
Please login to merge, or discard this patch.
app/Http/Controllers/Companies/Groups/EmployeesController.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -71,8 +71,9 @@
 block discarded – undo
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
     }
Please login to merge, or discard this patch.
app/Http/Controllers/Companies/Employees/EmployeesController.php 1 patch
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -53,8 +53,9 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
     }
Please login to merge, or discard this patch.
app/Employee.php 1 patch
Braces   +11 added lines, -8 removed lines patch added patch discarded remove patch
@@ -109,14 +109,16 @@  discard block
 block discarded – undo
109 109
     public function getEmailForPasswordReset()
110 110
     {
111 111
         list(, $caller) = debug_backtrace(false);
112
-        if(isset($caller['class']))
113
-            $caller = explode('\\', $caller['class']);
114
-        else
115
-            $caller = '';
112
+        if(isset($caller['class'])) {
113
+                    $caller = explode('\\', $caller['class']);
114
+        } else {
115
+                    $caller = '';
116
+        }
116 117
 
117 118
         //check if this function is called by email sender
118
-        if ((count($caller) && $caller[count($caller) - 1] == 'PasswordBroker') || (defined('HHVM_VERSION') && $caller == ''))
119
-            return $this->email;
119
+        if ((count($caller) && $caller[count($caller) - 1] == 'PasswordBroker') || (defined('HHVM_VERSION') && $caller == '')) {
120
+                    return $this->email;
121
+        }
120 122
         //return unique identify for token repository
121 123
         return $this->email . $this->company->id;
122 124
     }
@@ -128,8 +130,9 @@  discard block
 block discarded – undo
128 130
     public function belongsToGroup(Group $group)
129 131
     {
130 132
         $group = $this->groups()->where('id', $group->id)->first();
131
-        if(is_object($group) && $group->exists)
132
-            return true;
133
+        if(is_object($group) && $group->exists) {
134
+                    return true;
135
+        }
133 136
         return false;
134 137
     }
135 138
 
Please login to merge, or discard this patch.
app/Console/Commands/SyncCaldav/Sync.php 2 patches
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -1,21 +1,21 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Created by PhpStorm.
4
- * User: Claudio Cardinale <[email protected]>
5
- * Date: 03/12/15
6
- * Time: 2.33
7
- * This program is free software; you can redistribute it and/or
8
- * modify it under the terms of the GNU General Public License
9
- * as published by the Free Software Foundation; either version 2
10
- * of the License, or (at your option) any later version.
11
- * This program is distributed in the hope that it will be useful,
12
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
- * GNU General Public License for more details.
15
- * You should have received a copy of the GNU General Public License
16
- * along with this program; if not, write to the Free Software
17
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
18
- */
3
+     * Created by PhpStorm.
4
+     * User: Claudio Cardinale <[email protected]>
5
+     * Date: 03/12/15
6
+     * Time: 2.33
7
+     * This program is free software; you can redistribute it and/or
8
+     * modify it under the terms of the GNU General Public License
9
+     * as published by the Free Software Foundation; either version 2
10
+     * of the License, or (at your option) any later version.
11
+     * This program is distributed in the hope that it will be useful,
12
+     * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
+     * GNU General Public License for more details.
15
+     * You should have received a copy of the GNU General Public License
16
+     * along with this program; if not, write to the Free Software
17
+     * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
18
+     */
19 19
 
20 20
 namespace plunner\Console\Commands\SyncCaldav;
21 21
 
Please login to merge, or discard this patch.
Braces   +21 added lines, -17 removed lines patch added patch discarded remove patch
@@ -91,11 +91,11 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
             }
Please login to merge, or discard this patch.
app/Console/Commands/SyncCaldav/SyncCaldav.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -82,7 +82,7 @@
 block discarded – undo
82 82
     {
83 83
         $event = $this->schedule->command('sync:caldav '.$calendar->calendar_id)->withoutOverlapping();
84 84
         if($event->isDue($this->laravel))
85
-             $event->run($this->laravel);
85
+                $event->run($this->laravel);
86 86
     }
87 87
 
88 88
     /**
Please login to merge, or discard this patch.
Braces   +14 added lines, -10 removed lines patch added patch discarded remove patch
@@ -53,10 +53,11 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
     /**
Please login to merge, or discard this patch.
app/Http/Controllers/Employees/Calendars/CalendarsController.php 1 patch
Braces   +10 added lines, -7 removed lines patch added patch discarded remove patch
@@ -66,8 +66,9 @@  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 72
         $calendar->caldav()->create($input);
72 73
         //TODO test
73 74
         //TODO validator
@@ -107,15 +108,17 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
         }
Please login to merge, or discard this patch.
app/Console/Commands/Optimise/Optimise.php 2 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Created by PhpStorm.
4
- * User: claudio
5
- * Date: 12/12/15
6
- * Time: 15.41
7
- */
3
+     * Created by PhpStorm.
4
+     * User: claudio
5
+     * Date: 12/12/15
6
+     * Time: 15.41
7
+     */
8 8
 
9 9
 namespace plunner\Console\Commands\Optimise;
10 10
 
@@ -45,8 +45,8 @@  discard block
 block discarded – undo
45 45
     private $company;
46 46
 
47 47
     /**
48
-    * @var Schedule laravel schedule object needed to perform command in background
49
-    */
48
+     * @var Schedule laravel schedule object needed to perform command in background
49
+     */
50 50
     private $schedule;
51 51
 
52 52
     /**
@@ -413,7 +413,7 @@  discard block
 block discarded – undo
413 413
         $diff = explode(':',$diff->format('%R:%d:%h:%i:%s'));
414 414
         $diff = $diff[1]*86400 + $diff[2]*3600 + $diff[3]*60 + $diff[4];
415 415
         //if($diff[0] != '-' && $diff != 0)
416
-          //  throw new OptimiseException('timeslot time <= startTime');
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
Please login to merge, or discard this patch.
Braces   +10 added lines, -7 removed lines patch added patch discarded remove patch
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
             foreach($meetings as $meeting){
318 318
                 if($usersMeetingsTmp->contains('meeting_id', $meeting)){
319 319
                     $ret[$user][$meeting] = 1;
320
-                }else{
320
+                } else{
321 321
                     $ret[$user][$meeting] = 0;
322 322
                 }
323 323
             }
@@ -363,8 +363,9 @@  discard block
 block discarded – undo
363 363
     static private function fillTimeSlots(array $array, $id, \Illuminate\Support\Collection $timeSlots, $fill = '0')
364 364
     {
365 365
         foreach($timeSlots as $timeSlot) {
366
-            if(!isset($array[$id]))
367
-                $array[$id] = [];
366
+            if(!isset($array[$id])) {
367
+                            $array[$id] = [];
368
+            }
368 369
             $array[$id] = self::arrayPadInterval($array[$id], $timeSlot->time_start, $timeSlot->time_end, $fill);
369 370
         }
370 371
         return $array;
@@ -379,8 +380,9 @@  discard block
 block discarded – undo
379 380
     static private function fillRow(array $array, $id, $until, $fill = '0')
380 381
     {
381 382
         for($i = 1; $i <= $until; $i++){
382
-            if(!isset($array[$id][$i]))
383
-                $array[$id][$i] = $fill;
383
+            if(!isset($array[$id][$i])) {
384
+                            $array[$id][$i] = $fill;
385
+            }
384 386
         }
385 387
 
386 388
         return $array;
@@ -395,8 +397,9 @@  discard block
 block discarded – undo
395 397
      */
396 398
     static private function arrayPadInterval(array $array, $from, $to, $pad = '0')
397 399
     {
398
-        for($i = $from; $i<$to; $i++)
399
-            $array[$i] = $pad;
400
+        for($i = $from; $i<$to; $i++) {
401
+                    $array[$i] = $pad;
402
+        }
400 403
         return $array;
401 404
     }
402 405
 
Please login to merge, or discard this patch.