@@ -73,12 +73,12 @@ discard block |
||
73 | 73 | $caldavClient = new SimpleCaldavAdapter(); |
74 | 74 | $caldavClient->connect($this->calendar->url, $this->calendar->username, \Crypt::decrypt($this->calendar->password)); |
75 | 75 | $calendars = $caldavClient->findCalendars(); |
76 | - $caldavClient->setCalendar($calendars[$this->calendar->calendar_name]); |
|
76 | + $caldavClient->setCalendar($calendars[ $this->calendar->calendar_name ]); |
|
77 | 77 | /** |
78 | 78 | * 26 hours before to avoid tiemezone problems and dst problems |
79 | 79 | * 30 days after |
80 | 80 | */ |
81 | - return $caldavClient->getEvents(date('Ymd\THis\Z', time()-93600), date('Ymd\THis\Z', time()+2592000)); |
|
81 | + return $caldavClient->getEvents(date('Ymd\THis\Z', time() - 93600), date('Ymd\THis\Z', time() + 2592000)); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
@@ -89,13 +89,13 @@ 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 | - return ; |
|
96 | - }catch(\Illuminate\Contracts\Encryption\DecryptException $e){ |
|
95 | + return; |
|
96 | + } catch (\Illuminate\Contracts\Encryption\DecryptException $e) { |
|
97 | 97 | \Event::fire(new CaldavErrorEvent($this->calendar, $e->getMessage())); |
98 | - return ; |
|
98 | + return; |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | /** |
@@ -105,8 +105,8 @@ discard block |
||
105 | 105 | |
106 | 106 | //remove old timeslots |
107 | 107 | $calendarMain->timeslots()->delete(); |
108 | - foreach($events as $event){ |
|
109 | - if(!($event = $this->parseEvent($event))) |
|
108 | + foreach ($events as $event) { |
|
109 | + if (!($event = $this->parseEvent($event))) |
|
110 | 110 | \Event::fire(new CaldavErrorEvent($this->calendar, 'problem during the parsing an event')); |
111 | 111 | $calendarMain->timeslots()->create($event); |
112 | 112 | } |
@@ -119,16 +119,16 @@ discard block |
||
119 | 119 | private function parseEvent(EventInterface $event) |
120 | 120 | { |
121 | 121 | $pattern = "/^((DTSTART;)|(DTEND;))(.*)\$/m"; |
122 | - if(preg_match_all($pattern, $event->getData(), $matches)){ |
|
123 | - if(!isset($matches[4]) || count($matches[4]) != 2) |
|
122 | + if (preg_match_all($pattern, $event->getData(), $matches)) { |
|
123 | + if (!isset($matches[ 4 ]) || count($matches[ 4 ]) != 2) |
|
124 | 124 | return null; |
125 | - $ret = []; |
|
126 | - if($tmp = $this->parseDate($matches[4][0])) |
|
127 | - $ret['time_start'] = $tmp; |
|
125 | + $ret = [ ]; |
|
126 | + if ($tmp = $this->parseDate($matches[ 4 ][ 0 ])) |
|
127 | + $ret[ 'time_start' ] = $tmp; |
|
128 | 128 | else |
129 | 129 | return null; |
130 | - if($tmp = $this->parseDate($matches[4][1])) |
|
131 | - $ret['time_end'] = $tmp; |
|
130 | + if ($tmp = $this->parseDate($matches[ 4 ][ 1 ])) |
|
131 | + $ret[ 'time_end' ] = $tmp; |
|
132 | 132 | else |
133 | 133 | return null; |
134 | 134 | return $ret; |
@@ -143,13 +143,13 @@ discard block |
||
143 | 143 | private function parseDate($date) |
144 | 144 | { |
145 | 145 | $pattern = "/^((TZID=)|(VALUE=))(.*):(.*)\$/m"; |
146 | - if(preg_match_all($pattern, $date, $matches)){ |
|
147 | - if($matches[1][0] == 'TZID=') |
|
146 | + if (preg_match_all($pattern, $date, $matches)) { |
|
147 | + if ($matches[ 1 ][ 0 ] == 'TZID=') |
|
148 | 148 | { |
149 | - return \DateTime::createFromFormat('Ymd\THis', $matches[5][0], new \DateTimeZone($matches[4][0])); |
|
150 | - }else if($matches[1][0] == 'VALUE=' && $matches[4][0] == 'DATE') |
|
149 | + return \DateTime::createFromFormat('Ymd\THis', $matches[ 5 ][ 0 ], new \DateTimeZone($matches[ 4 ][ 0 ])); |
|
150 | + } else if ($matches[ 1 ][ 0 ] == 'VALUE=' && $matches[ 4 ][ 0 ] == 'DATE') |
|
151 | 151 | { |
152 | - return \DateTime::createFromFormat('Ymd\THis', $matches[5][0].'T000000'); |
|
152 | + return \DateTime::createFromFormat('Ymd\THis', $matches[ 5 ][ 0 ].'T000000'); |
|
153 | 153 | } |
154 | 154 | } |
155 | 155 | return null; |