@@ -54,8 +54,9 @@ |
||
54 | 54 | */ |
55 | 55 | public function Caldav() |
56 | 56 | { |
57 | - if($this->type == 'caldav') |
|
58 | - return $this->hasOne(Caldav::class); |
|
57 | + if($this->type == 'caldav') { |
|
58 | + return $this->hasOne(Caldav::class); |
|
59 | + } |
|
59 | 60 | return null; |
60 | 61 | } |
61 | 62 | } |
@@ -89,10 +89,10 @@ discard block |
||
89 | 89 | try |
90 | 90 | { |
91 | 91 | $events = $this->getEvents(); |
92 | - }catch (\it\thecsea\caldav_client_adapter\CaldavException $e) |
|
92 | + } catch (\it\thecsea\caldav_client_adapter\CaldavException $e) |
|
93 | 93 | { |
94 | 94 | \Event::fire(new CaldavErrorEvent($this->calendar, $e->getMessage())); |
95 | - }catch(\Illuminate\Contracts\Encryption\DecryptException $e){ |
|
95 | + } catch(\Illuminate\Contracts\Encryption\DecryptException $e){ |
|
96 | 96 | \Event::fire(new CaldavErrorEvent($this->calendar, $e->getMessage())); |
97 | 97 | } |
98 | 98 | |
@@ -104,8 +104,9 @@ discard block |
||
104 | 104 | //remove old timeslots |
105 | 105 | $calendarMain->timeslots()->delete(); |
106 | 106 | foreach($events as $event){ |
107 | - if(!($event = $this->parseEvent($event))) |
|
108 | - \Event::fire(new CaldavErrorEvent($this->calendar, 'problem during the parsing an event')); |
|
107 | + if(!($event = $this->parseEvent($event))) { |
|
108 | + \Event::fire(new CaldavErrorEvent($this->calendar, 'problem during the parsing an event')); |
|
109 | + } |
|
109 | 110 | $calendarMain->timeslots()->create($event); |
110 | 111 | } |
111 | 112 | } |
@@ -118,17 +119,20 @@ discard block |
||
118 | 119 | { |
119 | 120 | $pattern = "/^((DTSTART;)|(DTEND;))(.*)\$/m"; |
120 | 121 | if(preg_match_all($pattern, $event->getData(), $matches)){ |
121 | - if(!isset($matches[4]) || count($matches[4]) != 2) |
|
122 | - return null; |
|
122 | + if(!isset($matches[4]) || count($matches[4]) != 2) { |
|
123 | + return null; |
|
124 | + } |
|
123 | 125 | $ret = []; |
124 | - if($tmp = $this->parseDate($matches[4][0])) |
|
125 | - $ret['time_start'] = $tmp; |
|
126 | - else |
|
127 | - return null; |
|
128 | - if($tmp = $this->parseDate($matches[4][1])) |
|
129 | - $ret['time_end'] = $tmp; |
|
130 | - else |
|
131 | - return null; |
|
126 | + if($tmp = $this->parseDate($matches[4][0])) { |
|
127 | + $ret['time_start'] = $tmp; |
|
128 | + } else { |
|
129 | + return null; |
|
130 | + } |
|
131 | + if($tmp = $this->parseDate($matches[4][1])) { |
|
132 | + $ret['time_end'] = $tmp; |
|
133 | + } else { |
|
134 | + return null; |
|
135 | + } |
|
132 | 136 | return $ret; |
133 | 137 | } |
134 | 138 | return null; |
@@ -145,7 +149,7 @@ discard block |
||
145 | 149 | if($matches[1][0] == 'TZID=') |
146 | 150 | { |
147 | 151 | return \DateTime::createFromFormat('Ymd\THis', $matches[5][0], new \DateTimeZone($matches[4][0])); |
148 | - }else if($matches[1][0] == 'VALUE=' && $matches[4][0] == 'DATE') |
|
152 | + } else if($matches[1][0] == 'VALUE=' && $matches[4][0] == 'DATE') |
|
149 | 153 | { |
150 | 154 | return \DateTime::createFromFormat('Ymd\THis', $matches[5][0].'T000000'); |
151 | 155 | } |
@@ -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 | /** |