Completed
Push — master ( 2177e1...7159f1 )
by claudio
04:52
created
app/Console/Commands/SyncCaldav/Sync.php 1 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.