@@ -31,11 +31,11 @@ discard block |
||
31 | 31 | * @param DateTimeZone $time_zone |
32 | 32 | * @return array |
33 | 33 | */ |
34 | - private static function calculateTimeRangeForTransitions(DateTimeZone $time_zone){ |
|
34 | + private static function calculateTimeRangeForTransitions(DateTimeZone $time_zone) { |
|
35 | 35 | |
36 | 36 | $now = new DateTime('now', $time_zone); |
37 | 37 | $year = $now->format('Y'); |
38 | - return [new DateTime('1/1/'.$year, $time_zone), new DateTime('1/1/'.($year + 1), $time_zone)]; |
|
38 | + return [new DateTime('1/1/'.$year, $time_zone), new DateTime('1/1/'.($year + 1), $time_zone)]; |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
@@ -43,11 +43,11 @@ discard block |
||
43 | 43 | * @param int $former_offset |
44 | 44 | * @return DateTime |
45 | 45 | */ |
46 | - private static function convertStartDateFromUTC2Local(array $trans, $former_offset){ |
|
46 | + private static function convertStartDateFromUTC2Local(array $trans, $former_offset) { |
|
47 | 47 | $dt = new DateTime($trans['time'], new DateTimeZone('UTC')); |
48 | 48 | $hours = abs($former_offset); |
49 | 49 | // START TIME IS ON UTC and should be converted to local using former offset |
50 | - if($former_offset >= 0 ) |
|
50 | + if ($former_offset >= 0) |
|
51 | 51 | $dt->add(new DateInterval("PT{$hours}H")); |
52 | 52 | else |
53 | 53 | $dt->sub(new DateInterval("PT{$hours}H")); |
@@ -59,12 +59,11 @@ discard block |
||
59 | 59 | * @param DateTime $dt |
60 | 60 | * @return RecurrenceRule |
61 | 61 | */ |
62 | - private static function calculateRecurrenceRule(DateTime $dt){ |
|
63 | - $r_rule = new RecurrenceRule(); |
|
62 | + private static function calculateRecurrenceRule(DateTime $dt) { |
|
63 | + $r_rule = new RecurrenceRule(); |
|
64 | 64 | $r_rule->setFreq(RecurrenceRule::FREQ_YEARLY); |
65 | 65 | $r_rule->setByMonth(intval($dt->format('m'))); |
66 | - $r_rule->setByDay |
|
67 | - ( |
|
66 | + $r_rule->setByDay( |
|
68 | 67 | self::translate2ByDay($dt) |
69 | 68 | ); |
70 | 69 | return $r_rule; |
@@ -74,7 +73,7 @@ discard block |
||
74 | 73 | * @param $offset |
75 | 74 | * @return string |
76 | 75 | */ |
77 | - private static function calculateOffsetFrom($offset){ |
|
76 | + private static function calculateOffsetFrom($offset) { |
|
78 | 77 | return sprintf('%s%02d%02d', $offset >= 0 ? '+' : '-', abs($offset), abs(($offset - floor($offset)) * 60)); |
79 | 78 | } |
80 | 79 | |
@@ -82,7 +81,7 @@ discard block |
||
82 | 81 | * @param $offset |
83 | 82 | * @return string |
84 | 83 | */ |
85 | - private static function calculateOffsetTo($offset){ |
|
84 | + private static function calculateOffsetTo($offset) { |
|
86 | 85 | return sprintf('%s%02d%02d', $offset >= 0 ? '+' : '-', abs($offset), abs(($offset - floor($offset)) * 60)); |
87 | 86 | } |
88 | 87 | /** |
@@ -91,7 +90,7 @@ discard block |
||
91 | 90 | * @param bool $with_calendar_envelope |
92 | 91 | * @return Calendar|Timezone |
93 | 92 | */ |
94 | - public static function build(DateTimeZone $time_zone, $calendar_prod_id, $with_calendar_envelope = true){ |
|
93 | + public static function build(DateTimeZone $time_zone, $calendar_prod_id, $with_calendar_envelope = true) { |
|
95 | 94 | |
96 | 95 | // get all transitions for one current year and next |
97 | 96 | list($start_range, $end_range) = self::calculateTimeRangeForTransitions($time_zone); |
@@ -111,11 +110,11 @@ discard block |
||
111 | 110 | |
112 | 111 | // daylight saving time definition |
113 | 112 | if ($trans['isdst']) { |
114 | - $current_time_zone_rule = new TimezoneRule(TimezoneRule::TYPE_DAYLIGHT);; |
|
113 | + $current_time_zone_rule = new TimezoneRule(TimezoneRule::TYPE_DAYLIGHT); ; |
|
115 | 114 | } |
116 | 115 | // standard time definition |
117 | 116 | else { |
118 | - $current_time_zone_rule = new TimezoneRule(TimezoneRule::TYPE_STANDARD);; |
|
117 | + $current_time_zone_rule = new TimezoneRule(TimezoneRule::TYPE_STANDARD); ; |
|
119 | 118 | } |
120 | 119 | |
121 | 120 | if ($current_time_zone_rule) { |
@@ -136,7 +135,7 @@ discard block |
||
136 | 135 | } |
137 | 136 | |
138 | 137 | } |
139 | - if($with_calendar_envelope) { |
|
138 | + if ($with_calendar_envelope) { |
|
140 | 139 | $vCalendar = new Calendar(sprintf("'-//%s//EN'", $calendar_prod_id)); |
141 | 140 | $vCalendar->setTimezone($vTimezone); |
142 | 141 | return $vCalendar; |
@@ -156,25 +155,25 @@ discard block |
||
156 | 155 | * @param DateTime $dt) |
157 | 156 | * @return string |
158 | 157 | */ |
159 | - private static function translate2ByDay(DateTime $dt){ |
|
160 | - $day_name = substr(strtoupper($dt->format('D')), 0,2); |
|
158 | + private static function translate2ByDay(DateTime $dt) { |
|
159 | + $day_name = substr(strtoupper($dt->format('D')), 0, 2); |
|
161 | 160 | $ordinals = ['first', 'second', 'third', 'fourth', 'last']; |
162 | 161 | $day_nbr = 0; |
163 | 162 | $is_last = false; |
164 | 163 | |
165 | - foreach($ordinals as $idx => $ord){ |
|
164 | + foreach ($ordinals as $idx => $ord) { |
|
166 | 165 | $dt_n = self::buildOrdinalDateTime($ord, $dt); |
167 | - if($dt_n->format('Y-m-d') == $dt->format('Y-m-d')){ |
|
168 | - $day_nbr = $idx + 1; |
|
169 | - if($ord == 'last'){ |
|
166 | + if ($dt_n->format('Y-m-d') == $dt->format('Y-m-d')) { |
|
167 | + $day_nbr = $idx + 1; |
|
168 | + if ($ord == 'last') { |
|
170 | 169 | $is_last = true; |
171 | - $day_nbr = 1; |
|
170 | + $day_nbr = 1; |
|
172 | 171 | } |
173 | 172 | break; |
174 | 173 | } |
175 | 174 | } |
176 | 175 | |
177 | - return sprintf('%s%s%s', $is_last? '-':'', $day_nbr, $day_name); |
|
176 | + return sprintf('%s%s%s', $is_last ? '-' : '', $day_nbr, $day_name); |
|
178 | 177 | } |
179 | 178 | |
180 | 179 | /** |
@@ -182,15 +181,11 @@ discard block |
||
182 | 181 | * @param DateTime $dt |
183 | 182 | * @return DateTime |
184 | 183 | */ |
185 | - private static function buildOrdinalDateTime($ord, DateTime $dt){ |
|
186 | - return new DateTime |
|
187 | - ( |
|
188 | - date |
|
189 | - ("Y-m-d", |
|
190 | - strtotime |
|
191 | - ( |
|
192 | - sprintf |
|
193 | - ( |
|
184 | + private static function buildOrdinalDateTime($ord, DateTime $dt) { |
|
185 | + return new DateTime( |
|
186 | + date("Y-m-d", |
|
187 | + strtotime( |
|
188 | + sprintf( |
|
194 | 189 | self::GetOrdinalDayQuery, |
195 | 190 | $ord, |
196 | 191 | $dt->format('l'), |
@@ -47,10 +47,11 @@ |
||
47 | 47 | $dt = new DateTime($trans['time'], new DateTimeZone('UTC')); |
48 | 48 | $hours = abs($former_offset); |
49 | 49 | // START TIME IS ON UTC and should be converted to local using former offset |
50 | - if($former_offset >= 0 ) |
|
51 | - $dt->add(new DateInterval("PT{$hours}H")); |
|
52 | - else |
|
53 | - $dt->sub(new DateInterval("PT{$hours}H")); |
|
50 | + if($former_offset >= 0 ) { |
|
51 | + $dt->add(new DateInterval("PT{$hours}H")); |
|
52 | + } else { |
|
53 | + $dt->sub(new DateInterval("PT{$hours}H")); |
|
54 | + } |
|
54 | 55 | |
55 | 56 | return $dt; |
56 | 57 | } |
@@ -25,9 +25,9 @@ discard block |
||
25 | 25 | |
26 | 26 | protected function parse() |
27 | 27 | { |
28 | - if(isset($this->content['response'])){ |
|
28 | + if (isset($this->content['response'])) { |
|
29 | 29 | |
30 | - if(isset($this->content['response']['propstat'])) { |
|
30 | + if (isset($this->content['response']['propstat'])) { |
|
31 | 31 | // its a collection with one single element |
32 | 32 | $single_resource = $this->buildSingleResponse(); |
33 | 33 | $single_resource->setContent(['response' => $this->content['response']]); |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | /** |
49 | 49 | * @return GenericSinglePROPFINDCalDAVResponse[] |
50 | 50 | */ |
51 | - public function getResponses(){ |
|
51 | + public function getResponses() { |
|
52 | 52 | return $this->responses; |
53 | 53 | } |
54 | 54 |
@@ -21,7 +21,7 @@ |
||
21 | 21 | /** |
22 | 22 | * @return string |
23 | 23 | */ |
24 | - public function getVCard(){ |
|
24 | + public function getVCard() { |
|
25 | 25 | return isset($this->found_props['calendar-data']) ? $this->found_props['calendar-data'] : null; |
26 | 26 | } |
27 | 27 | } |
28 | 28 | \ No newline at end of file |
@@ -21,7 +21,7 @@ |
||
21 | 21 | /** |
22 | 22 | * @return bool |
23 | 23 | */ |
24 | - public function isSuccessFull(){ |
|
24 | + public function isSuccessFull() { |
|
25 | 25 | return $this->code == HttpResponse::HttpCodeNoContent; |
26 | 26 | } |
27 | 27 | } |
28 | 28 | \ No newline at end of file |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | $this->timezone = $timezone; |
61 | 61 | $this->uid = md5(uniqid(mt_rand(), true)); |
62 | 62 | |
63 | - if(is_null($this->timezone)){ |
|
63 | + if (is_null($this->timezone)) { |
|
64 | 64 | $this->timezone = new DateTimeZone('UTC'); |
65 | 65 | } |
66 | 66 | } |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | /** |
69 | 69 | * @param string $uid |
70 | 70 | */ |
71 | - public function setUID($uid){ |
|
71 | + public function setUID($uid) { |
|
72 | 72 | $this->uid = $uid; |
73 | 73 | } |
74 | 74 |
@@ -50,21 +50,21 @@ discard block |
||
50 | 50 | ]; |
51 | 51 | case HttpMethods::Put: |
52 | 52 | $etag = $params[0]; |
53 | - if(!empty($etag)){ |
|
54 | - return [ |
|
55 | - Headers::ContentType => ContentTypes::Calendar, |
|
56 | - Headers::IfMatch => $etag |
|
57 | - ]; |
|
58 | - } |
|
53 | + if(!empty($etag)){ |
|
54 | + return [ |
|
55 | + Headers::ContentType => ContentTypes::Calendar, |
|
56 | + Headers::IfMatch => $etag |
|
57 | + ]; |
|
58 | + } |
|
59 | 59 | } |
60 | 60 | return []; |
61 | 61 | } |
62 | 62 | /** |
63 | - * @param string $url |
|
64 | - * @param string $body |
|
65 | - * @param int $depth |
|
66 | - * @return Request |
|
67 | - */ |
|
63 | + * @param string $url |
|
64 | + * @param string $body |
|
65 | + * @param int $depth |
|
66 | + * @return Request |
|
67 | + */ |
|
68 | 68 | public static function createPropFindRequest($url , $body, $depth = 1){ |
69 | 69 | return new Request |
70 | 70 | ( |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | * @param string $etag |
154 | 154 | * @return Request |
155 | 155 | */ |
156 | - public static function createPutRequest($url, $body, $etag = null){ |
|
156 | + public static function createPutRequest($url, $body, $etag = null){ |
|
157 | 157 | return new Request |
158 | 158 | ( |
159 | 159 | HttpMethods::Put, |
@@ -26,8 +26,8 @@ discard block |
||
26 | 26 | * @param array $params |
27 | 27 | * @return array |
28 | 28 | */ |
29 | - private static function createHeadersFor($http_method, array $params = []){ |
|
30 | - switch ($http_method){ |
|
29 | + private static function createHeadersFor($http_method, array $params = []) { |
|
30 | + switch ($http_method) { |
|
31 | 31 | case HttpMethods::PropFind: |
32 | 32 | case HttpMethods::Options: |
33 | 33 | case HttpMethods::Report: |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | ]; |
39 | 39 | case HttpMethods::Delete: |
40 | 40 | $etag = $params[0]; |
41 | - if(!empty($etag)) { |
|
41 | + if (!empty($etag)) { |
|
42 | 42 | return [ |
43 | 43 | Headers::IfMatch => $etag, |
44 | 44 | ]; |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | ]; |
51 | 51 | case HttpMethods::Put: |
52 | 52 | $etag = $params[0]; |
53 | - if(!empty($etag)){ |
|
53 | + if (!empty($etag)) { |
|
54 | 54 | return [ |
55 | 55 | Headers::ContentType => ContentTypes::Calendar, |
56 | 56 | Headers::IfMatch => $etag |
@@ -65,11 +65,10 @@ discard block |
||
65 | 65 | * @param int $depth |
66 | 66 | * @return Request |
67 | 67 | */ |
68 | - public static function createPropFindRequest($url , $body, $depth = 1){ |
|
69 | - return new Request |
|
70 | - ( |
|
68 | + public static function createPropFindRequest($url, $body, $depth = 1) { |
|
69 | + return new Request( |
|
71 | 70 | HttpMethods::PropFind, |
72 | - $url , |
|
71 | + $url, |
|
73 | 72 | self::createHeadersFor(HttpMethods::PropFind, [$depth]), |
74 | 73 | $body |
75 | 74 | ); |
@@ -80,9 +79,8 @@ discard block |
||
80 | 79 | * @param string $body |
81 | 80 | * @return Request |
82 | 81 | */ |
83 | - public static function createMakeCalendarRequest($url , $body){ |
|
84 | - return new Request |
|
85 | - ( |
|
82 | + public static function createMakeCalendarRequest($url, $body) { |
|
83 | + return new Request( |
|
86 | 84 | HttpMethods::MakeCalendar, |
87 | 85 | $url, |
88 | 86 | self::createHeadersFor(HttpMethods::MakeCalendar), |
@@ -95,9 +93,8 @@ discard block |
||
95 | 93 | * @param int $depth |
96 | 94 | * @return Request |
97 | 95 | */ |
98 | - public static function createOptionsRequest($url, $depth = 1){ |
|
99 | - return new Request |
|
100 | - ( |
|
96 | + public static function createOptionsRequest($url, $depth = 1) { |
|
97 | + return new Request( |
|
101 | 98 | HttpMethods::Options, |
102 | 99 | $url, |
103 | 100 | self::createHeadersFor(HttpMethods::Options, [$depth]) |
@@ -110,9 +107,8 @@ discard block |
||
110 | 107 | * @param int $depth |
111 | 108 | * @return Request |
112 | 109 | */ |
113 | - public static function createReportRequest($url , $body, $depth = 1){ |
|
114 | - return new Request |
|
115 | - ( |
|
110 | + public static function createReportRequest($url, $body, $depth = 1) { |
|
111 | + return new Request( |
|
116 | 112 | HttpMethods::Report, |
117 | 113 | $url, |
118 | 114 | self::createHeadersFor(HttpMethods::Report, [$depth]), |
@@ -125,9 +121,8 @@ discard block |
||
125 | 121 | * @param string $etag |
126 | 122 | * @return Request |
127 | 123 | */ |
128 | - public static function createDeleteRequest($url , $etag){ |
|
129 | - return new Request |
|
130 | - ( |
|
124 | + public static function createDeleteRequest($url, $etag) { |
|
125 | + return new Request( |
|
131 | 126 | HttpMethods::Delete, |
132 | 127 | $url, |
133 | 128 | self::createHeadersFor(HttpMethods::Delete, [$etag]) |
@@ -138,9 +133,8 @@ discard block |
||
138 | 133 | * @param string $url |
139 | 134 | * @return Request |
140 | 135 | */ |
141 | - public static function createGetRequest($url){ |
|
142 | - return new Request |
|
143 | - ( |
|
136 | + public static function createGetRequest($url) { |
|
137 | + return new Request( |
|
144 | 138 | HttpMethods::Get, |
145 | 139 | $url, |
146 | 140 | self::createHeadersFor(HttpMethods::Get) |
@@ -153,9 +147,8 @@ discard block |
||
153 | 147 | * @param string $etag |
154 | 148 | * @return Request |
155 | 149 | */ |
156 | - public static function createPutRequest($url, $body, $etag = null){ |
|
157 | - return new Request |
|
158 | - ( |
|
150 | + public static function createPutRequest($url, $body, $etag = null) { |
|
151 | + return new Request( |
|
159 | 152 | HttpMethods::Put, |
160 | 153 | $url, |
161 | 154 | self::createHeadersFor(HttpMethods::Put, [$etag]), |
@@ -137,15 +137,15 @@ discard block |
||
137 | 137 | * @param Request $http_request |
138 | 138 | * @return mixed|\Psr\Http\Message\ResponseInterface |
139 | 139 | */ |
140 | - private function makeRequest(Request $http_request){ |
|
141 | - try{ |
|
140 | + private function makeRequest(Request $http_request) { |
|
141 | + try { |
|
142 | 142 | return $this->client->send($http_request, [ |
143 | 143 | 'auth' => [$this->user, $this->password, $this->authtype], |
144 | 144 | 'timeout' => $this->timeout |
145 | 145 | ]); |
146 | 146 | } |
147 | - catch (ClientException $ex){ |
|
148 | - switch($ex->getCode()){ |
|
147 | + catch (ClientException $ex) { |
|
148 | + switch ($ex->getCode()) { |
|
149 | 149 | case 401: |
150 | 150 | throw new UserUnAuthorizedException(); |
151 | 151 | break; |
@@ -173,9 +173,9 @@ discard block |
||
173 | 173 | |
174 | 174 | $res = $http_response->hasHeader(self::DAVHeader); |
175 | 175 | $options = []; |
176 | - if($res){ |
|
176 | + if ($res) { |
|
177 | 177 | $val = $http_response->getHeaderLine(self::DAVHeader); |
178 | - if(!empty($val)){ |
|
178 | + if (!empty($val)) { |
|
179 | 179 | $options = explode(', ', $val); |
180 | 180 | } |
181 | 181 | } |
@@ -189,14 +189,13 @@ discard block |
||
189 | 189 | public function getUserPrincipal() |
190 | 190 | { |
191 | 191 | $http_response = $this->makeRequest( |
192 | - RequestFactory::createPropFindRequest |
|
193 | - ( |
|
192 | + RequestFactory::createPropFindRequest( |
|
194 | 193 | $this->server_url, |
195 | 194 | CalDAVRequestFactory::getInstance()->build(CalDAVRequestFactory::PrincipalRequestType)->getContent() |
196 | 195 | ) |
197 | 196 | ); |
198 | 197 | |
199 | - return new UserPrincipalResponse($this->server_url, (string)$http_response->getBody(), $http_response->getStatusCode()); |
|
198 | + return new UserPrincipalResponse($this->server_url, (string) $http_response->getBody(), $http_response->getStatusCode()); |
|
200 | 199 | } |
201 | 200 | |
202 | 201 | /** |
@@ -206,14 +205,13 @@ discard block |
||
206 | 205 | public function getCalendarHome($principal_url) |
207 | 206 | { |
208 | 207 | $http_response = $this->makeRequest( |
209 | - RequestFactory::createPropFindRequest |
|
210 | - ( |
|
208 | + RequestFactory::createPropFindRequest( |
|
211 | 209 | $principal_url, |
212 | 210 | CalDAVRequestFactory::getInstance()->build(CalDAVRequestFactory::CalendarHomeRequestType)->getContent() |
213 | 211 | ) |
214 | 212 | ); |
215 | 213 | |
216 | - return new CalendarHomesResponse($this->server_url, (string)$http_response->getBody(), $http_response->getStatusCode()); |
|
214 | + return new CalendarHomesResponse($this->server_url, (string) $http_response->getBody(), $http_response->getStatusCode()); |
|
217 | 215 | } |
218 | 216 | |
219 | 217 | /** |
@@ -227,8 +225,7 @@ discard block |
||
227 | 225 | $uid = $vo->getUID(); |
228 | 226 | $resource_url = $calendar_home_set.$uid; |
229 | 227 | $http_response = $this->makeRequest( |
230 | - RequestFactory::createMakeCalendarRequest |
|
231 | - ( |
|
228 | + RequestFactory::createMakeCalendarRequest( |
|
232 | 229 | $resource_url, |
233 | 230 | CalDAVRequestFactory::getInstance()->build(CalDAVRequestFactory::CalendarCreateRequestType, [$vo])->getContent() |
234 | 231 | ) |
@@ -244,14 +241,13 @@ discard block |
||
244 | 241 | public function getCalendars($calendar_home_set_url) |
245 | 242 | { |
246 | 243 | $http_response = $this->makeRequest( |
247 | - RequestFactory::createPropFindRequest |
|
248 | - ( |
|
244 | + RequestFactory::createPropFindRequest( |
|
249 | 245 | $calendar_home_set_url, |
250 | 246 | CalDAVRequestFactory::getInstance()->build(CalDAVRequestFactory::CalendarsRequestType)->getContent() |
251 | 247 | ) |
252 | 248 | ); |
253 | 249 | |
254 | - return new GetCalendarsResponse($this->server_url, (string)$http_response->getBody(), $http_response->getStatusCode()); |
|
250 | + return new GetCalendarsResponse($this->server_url, (string) $http_response->getBody(), $http_response->getStatusCode()); |
|
255 | 251 | } |
256 | 252 | |
257 | 253 | /** |
@@ -261,15 +257,14 @@ discard block |
||
261 | 257 | public function getCalendar($calendar_url) |
262 | 258 | { |
263 | 259 | $http_response = $this->makeRequest( |
264 | - RequestFactory::createPropFindRequest |
|
265 | - ( |
|
260 | + RequestFactory::createPropFindRequest( |
|
266 | 261 | $calendar_url, |
267 | 262 | CalDAVRequestFactory::getInstance()->build(CalDAVRequestFactory::CalendarRequestType)->getContent(), |
268 | 263 | 0 |
269 | 264 | ) |
270 | 265 | ); |
271 | 266 | |
272 | - return new GetCalendarResponse($this->server_url, (string)$http_response->getBody(), $http_response->getStatusCode()); |
|
267 | + return new GetCalendarResponse($this->server_url, (string) $http_response->getBody(), $http_response->getStatusCode()); |
|
273 | 268 | } |
274 | 269 | |
275 | 270 | |
@@ -282,14 +277,13 @@ discard block |
||
282 | 277 | { |
283 | 278 | |
284 | 279 | $http_response = $this->makeRequest( |
285 | - RequestFactory::createReportRequest |
|
286 | - ( |
|
280 | + RequestFactory::createReportRequest( |
|
287 | 281 | $calendar_url, |
288 | 282 | CalDAVRequestFactory::getInstance()->build(CalDAVRequestFactory::CalendarSyncRequestType, [$sync_token])->getContent() |
289 | 283 | ) |
290 | 284 | ); |
291 | 285 | |
292 | - return new CalendarSyncInfoResponse($this->server_url, (string)$http_response->getBody(), $http_response->getStatusCode()); |
|
286 | + return new CalendarSyncInfoResponse($this->server_url, (string) $http_response->getBody(), $http_response->getStatusCode()); |
|
293 | 287 | } |
294 | 288 | |
295 | 289 | /** |
@@ -302,19 +296,17 @@ discard block |
||
302 | 296 | $uid = $vo->getUID(); |
303 | 297 | $resource_url = $calendar_url.$uid.self::SchedulingInformationSuffix; |
304 | 298 | $http_response = $this->makeRequest( |
305 | - RequestFactory::createPutRequest |
|
306 | - ( |
|
299 | + RequestFactory::createPutRequest( |
|
307 | 300 | $resource_url, |
308 | 301 | CalDAVRequestFactory::getInstance()->build(CalDAVRequestFactory::EventCreateRequestType, [$vo])->getContent() |
309 | 302 | ) |
310 | 303 | ); |
311 | 304 | $etag = $http_response->hasHeader(self::ETagHeader) ? $http_response->getHeaderLine(self::ETagHeader) : null; |
312 | - return new EventCreatedResponse |
|
313 | - ( |
|
305 | + return new EventCreatedResponse( |
|
314 | 306 | $uid, |
315 | 307 | $etag, |
316 | 308 | $resource_url, |
317 | - (string)$http_response->getBody(), |
|
309 | + (string) $http_response->getBody(), |
|
318 | 310 | $http_response->getStatusCode() |
319 | 311 | ); |
320 | 312 | } |
@@ -330,20 +322,18 @@ discard block |
||
330 | 322 | $uid = $vo->getUID(); |
331 | 323 | $resource_url = $calendar_url.$uid.self::SchedulingInformationSuffix; |
332 | 324 | $http_response = $this->makeRequest( |
333 | - RequestFactory::createPutRequest |
|
334 | - ( |
|
325 | + RequestFactory::createPutRequest( |
|
335 | 326 | $resource_url, |
336 | 327 | CalDAVRequestFactory::getInstance()->build(CalDAVRequestFactory::EventUpdateRequestType, [$vo])->getContent(), |
337 | 328 | $etag |
338 | 329 | ) |
339 | 330 | ); |
340 | 331 | $etag = $http_response->hasHeader(self::ETagHeader) ? $http_response->getHeaderLine(self::ETagHeader) : null; |
341 | - return new EventUpdatedResponse |
|
342 | - ( |
|
332 | + return new EventUpdatedResponse( |
|
343 | 333 | $uid, |
344 | 334 | $etag, |
345 | 335 | $resource_url, |
346 | - (string)$http_response->getBody(), |
|
336 | + (string) $http_response->getBody(), |
|
347 | 337 | $http_response->getStatusCode() |
348 | 338 | ); |
349 | 339 | } |
@@ -357,16 +347,14 @@ discard block |
||
357 | 347 | public function deleteEvent($calendar_url, $uid, $etag = null) |
358 | 348 | { |
359 | 349 | $http_response = $this->makeRequest( |
360 | - RequestFactory::createDeleteRequest |
|
361 | - ( |
|
350 | + RequestFactory::createDeleteRequest( |
|
362 | 351 | $calendar_url.$uid.self::SchedulingInformationSuffix, |
363 | 352 | $etag |
364 | 353 | ) |
365 | 354 | ); |
366 | 355 | |
367 | - return new EventDeletedResponse |
|
368 | - ( |
|
369 | - (string)$http_response->getBody(), $http_response->getStatusCode() |
|
356 | + return new EventDeletedResponse( |
|
357 | + (string) $http_response->getBody(), $http_response->getStatusCode() |
|
370 | 358 | ); |
371 | 359 | } |
372 | 360 | |
@@ -374,15 +362,14 @@ discard block |
||
374 | 362 | * @param string $event_url |
375 | 363 | * @return string |
376 | 364 | */ |
377 | - public function getEventVCardBy($event_url){ |
|
365 | + public function getEventVCardBy($event_url) { |
|
378 | 366 | $http_response = $this->makeRequest( |
379 | - RequestFactory::createGetRequest |
|
380 | - ( |
|
367 | + RequestFactory::createGetRequest( |
|
381 | 368 | $event_url |
382 | 369 | ) |
383 | 370 | ); |
384 | 371 | |
385 | - $ical = (string)$http_response->getBody(); |
|
372 | + $ical = (string) $http_response->getBody(); |
|
386 | 373 | return $ical; |
387 | 374 | } |
388 | 375 | |
@@ -394,17 +381,15 @@ discard block |
||
394 | 381 | public function getEventsBy($calendar_url, array $events_urls) |
395 | 382 | { |
396 | 383 | $http_response = $this->makeRequest( |
397 | - RequestFactory::createReportRequest |
|
398 | - ( |
|
384 | + RequestFactory::createReportRequest( |
|
399 | 385 | $calendar_url, |
400 | 386 | CalDAVRequestFactory::getInstance()->build(CalDAVRequestFactory::CalendarMultiGetRequestType, [$events_urls])->getContent() |
401 | 387 | ) |
402 | 388 | ); |
403 | 389 | |
404 | - return new ResourceCollectionResponse |
|
405 | - ( |
|
390 | + return new ResourceCollectionResponse( |
|
406 | 391 | $this->server_url, |
407 | - (string)$http_response->getBody(), |
|
392 | + (string) $http_response->getBody(), |
|
408 | 393 | $http_response->getStatusCode() |
409 | 394 | ); |
410 | 395 | } |
@@ -418,17 +403,15 @@ discard block |
||
418 | 403 | { |
419 | 404 | |
420 | 405 | $http_response = $this->makeRequest( |
421 | - RequestFactory::createReportRequest |
|
422 | - ( |
|
406 | + RequestFactory::createReportRequest( |
|
423 | 407 | $calendar_url, |
424 | 408 | CalDAVRequestFactory::getInstance()->build(CalDAVRequestFactory::CalendarQueryRequestType, [$filter])->getContent() |
425 | 409 | ) |
426 | 410 | ); |
427 | 411 | |
428 | - return new ResourceCollectionResponse |
|
429 | - ( |
|
412 | + return new ResourceCollectionResponse( |
|
430 | 413 | $this->server_url, |
431 | - (string)$http_response->getBody(), |
|
414 | + (string) $http_response->getBody(), |
|
432 | 415 | $http_response->getStatusCode() |
433 | 416 | ); |
434 | 417 | } |
@@ -441,16 +424,14 @@ discard block |
||
441 | 424 | public function deleteCalendar($calendar_url, $etag = null) |
442 | 425 | { |
443 | 426 | $http_response = $this->makeRequest( |
444 | - RequestFactory::createDeleteRequest |
|
445 | - ( |
|
427 | + RequestFactory::createDeleteRequest( |
|
446 | 428 | $calendar_url, |
447 | 429 | $etag |
448 | 430 | ) |
449 | 431 | ); |
450 | 432 | |
451 | - return new CalendarDeletedResponse |
|
452 | - ( |
|
453 | - $this->server_url, (string)$http_response->getBody(), $http_response->getStatusCode() |
|
433 | + return new CalendarDeletedResponse( |
|
434 | + $this->server_url, (string) $http_response->getBody(), $http_response->getStatusCode() |
|
454 | 435 | ); |
455 | 436 | } |
456 | 437 | } |
@@ -143,8 +143,7 @@ |
||
143 | 143 | 'auth' => [$this->user, $this->password, $this->authtype], |
144 | 144 | 'timeout' => $this->timeout |
145 | 145 | ]); |
146 | - } |
|
147 | - catch (ClientException $ex){ |
|
146 | + } catch (ClientException $ex){ |
|
148 | 147 | switch($ex->getCode()){ |
149 | 148 | case 401: |
150 | 149 | throw new UserUnAuthorizedException(); |