@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | * @param string $authtype |
109 | 109 | * @param array $headers Additional headers to send with each request |
110 | 110 | */ |
111 | - public function __construct($server_url, $user = null, $password = null, $authtype = self::DefaultAuthType, $headers=[]) |
|
111 | + public function __construct($server_url, $user = null, $password = null, $authtype = self::DefaultAuthType, $headers = []) |
|
112 | 112 | { |
113 | 113 | $this->server_url = $server_url; |
114 | 114 | $this->user = $user; |
@@ -157,8 +157,8 @@ discard block |
||
157 | 157 | * @return mixed|\Psr\Http\Message\ResponseInterface |
158 | 158 | * @throws \GuzzleHttp\Exception\GuzzleException |
159 | 159 | */ |
160 | - private function makeRequest(Request $http_request){ |
|
161 | - try{ |
|
160 | + private function makeRequest(Request $http_request) { |
|
161 | + try { |
|
162 | 162 | $options = [ |
163 | 163 | 'timeout' => $this->timeout |
164 | 164 | ]; |
@@ -176,8 +176,8 @@ discard block |
||
176 | 176 | |
177 | 177 | return $this->client->send($http_request, $options); |
178 | 178 | } |
179 | - catch (ClientException $ex){ |
|
180 | - switch($ex->getCode()){ |
|
179 | + catch (ClientException $ex) { |
|
180 | + switch ($ex->getCode()) { |
|
181 | 181 | case 401: |
182 | 182 | throw new UserUnAuthorizedException(); |
183 | 183 | break; |
@@ -210,9 +210,9 @@ discard block |
||
210 | 210 | |
211 | 211 | $res = $http_response->hasHeader(self::DAVHeader); |
212 | 212 | $options = []; |
213 | - if($res){ |
|
213 | + if ($res) { |
|
214 | 214 | $val = $http_response->getHeaderLine(self::DAVHeader); |
215 | - if(!empty($val)){ |
|
215 | + if (!empty($val)) { |
|
216 | 216 | $options = explode(', ', $val); |
217 | 217 | } |
218 | 218 | } |
@@ -226,14 +226,13 @@ discard block |
||
226 | 226 | public function getUserPrincipal() |
227 | 227 | { |
228 | 228 | $http_response = $this->makeRequest( |
229 | - RequestFactory::createPropFindRequest |
|
230 | - ( |
|
229 | + RequestFactory::createPropFindRequest( |
|
231 | 230 | $this->server_url, |
232 | 231 | CalDAVRequestFactory::getInstance()->build(CalDAVRequestFactory::PrincipalRequestType)->getContent() |
233 | 232 | ) |
234 | 233 | ); |
235 | 234 | |
236 | - return new UserPrincipalResponse($this->server_url, (string)$http_response->getBody(), $http_response->getStatusCode()); |
|
235 | + return new UserPrincipalResponse($this->server_url, (string) $http_response->getBody(), $http_response->getStatusCode()); |
|
237 | 236 | } |
238 | 237 | |
239 | 238 | /** |
@@ -244,14 +243,13 @@ discard block |
||
244 | 243 | public function getCalendarHome($principal_url) |
245 | 244 | { |
246 | 245 | $http_response = $this->makeRequest( |
247 | - RequestFactory::createPropFindRequest |
|
248 | - ( |
|
246 | + RequestFactory::createPropFindRequest( |
|
249 | 247 | $principal_url, |
250 | 248 | CalDAVRequestFactory::getInstance()->build(CalDAVRequestFactory::CalendarHomeRequestType)->getContent() |
251 | 249 | ) |
252 | 250 | ); |
253 | 251 | |
254 | - return new CalendarHomesResponse($this->server_url, (string)$http_response->getBody(), $http_response->getStatusCode()); |
|
252 | + return new CalendarHomesResponse($this->server_url, (string) $http_response->getBody(), $http_response->getStatusCode()); |
|
255 | 253 | } |
256 | 254 | |
257 | 255 | /** |
@@ -266,10 +264,9 @@ discard block |
||
266 | 264 | $uid = $vo->getUID(); |
267 | 265 | $resource_name = $vo->getResourceName(); |
268 | 266 | |
269 | - $resource_url = $calendar_home_set . ($resource_name ? $resource_name : $uid); |
|
267 | + $resource_url = $calendar_home_set.($resource_name ? $resource_name : $uid); |
|
270 | 268 | $http_response = $this->makeRequest( |
271 | - RequestFactory::createMakeCalendarRequest |
|
272 | - ( |
|
269 | + RequestFactory::createMakeCalendarRequest( |
|
273 | 270 | $resource_url, |
274 | 271 | CalDAVRequestFactory::getInstance()->build(CalDAVRequestFactory::CalendarCreateRequestType, [$vo])->getContent() |
275 | 272 | ) |
@@ -286,14 +283,13 @@ discard block |
||
286 | 283 | public function getCalendars($calendar_home_set_url) |
287 | 284 | { |
288 | 285 | $http_response = $this->makeRequest( |
289 | - RequestFactory::createPropFindRequest |
|
290 | - ( |
|
286 | + RequestFactory::createPropFindRequest( |
|
291 | 287 | $calendar_home_set_url, |
292 | 288 | CalDAVRequestFactory::getInstance()->build(CalDAVRequestFactory::CalendarsRequestType)->getContent() |
293 | 289 | ) |
294 | 290 | ); |
295 | 291 | |
296 | - return new GetCalendarsResponse($this->server_url, (string)$http_response->getBody(), $http_response->getStatusCode()); |
|
292 | + return new GetCalendarsResponse($this->server_url, (string) $http_response->getBody(), $http_response->getStatusCode()); |
|
297 | 293 | } |
298 | 294 | |
299 | 295 | /** |
@@ -304,15 +300,14 @@ discard block |
||
304 | 300 | public function getCalendar($calendar_url) |
305 | 301 | { |
306 | 302 | $http_response = $this->makeRequest( |
307 | - RequestFactory::createPropFindRequest |
|
308 | - ( |
|
303 | + RequestFactory::createPropFindRequest( |
|
309 | 304 | $calendar_url, |
310 | 305 | CalDAVRequestFactory::getInstance()->build(CalDAVRequestFactory::CalendarRequestType)->getContent(), |
311 | 306 | 0 |
312 | 307 | ) |
313 | 308 | ); |
314 | 309 | |
315 | - return new GetCalendarResponse($this->server_url, (string)$http_response->getBody(), $http_response->getStatusCode()); |
|
310 | + return new GetCalendarResponse($this->server_url, (string) $http_response->getBody(), $http_response->getStatusCode()); |
|
316 | 311 | } |
317 | 312 | |
318 | 313 | |
@@ -326,14 +321,13 @@ discard block |
||
326 | 321 | { |
327 | 322 | |
328 | 323 | $http_response = $this->makeRequest( |
329 | - RequestFactory::createReportRequest |
|
330 | - ( |
|
324 | + RequestFactory::createReportRequest( |
|
331 | 325 | $calendar_url, |
332 | 326 | CalDAVRequestFactory::getInstance()->build(CalDAVRequestFactory::CalendarSyncRequestType, [$sync_token])->getContent() |
333 | 327 | ) |
334 | 328 | ); |
335 | 329 | |
336 | - return new CalendarSyncInfoResponse($this->server_url, (string)$http_response->getBody(), $http_response->getStatusCode()); |
|
330 | + return new CalendarSyncInfoResponse($this->server_url, (string) $http_response->getBody(), $http_response->getStatusCode()); |
|
337 | 331 | } |
338 | 332 | |
339 | 333 | /** |
@@ -347,19 +341,17 @@ discard block |
||
347 | 341 | $uid = $vo->getUID(); |
348 | 342 | $resource_url = $calendar_url.$uid.self::SchedulingInformationSuffix; |
349 | 343 | $http_response = $this->makeRequest( |
350 | - RequestFactory::createPutRequest |
|
351 | - ( |
|
344 | + RequestFactory::createPutRequest( |
|
352 | 345 | $resource_url, |
353 | 346 | CalDAVRequestFactory::getInstance()->build(CalDAVRequestFactory::EventCreateRequestType, [$vo])->getContent() |
354 | 347 | ) |
355 | 348 | ); |
356 | 349 | $etag = $http_response->hasHeader(self::ETagHeader) ? $http_response->getHeaderLine(self::ETagHeader) : null; |
357 | - return new EventCreatedResponse |
|
358 | - ( |
|
350 | + return new EventCreatedResponse( |
|
359 | 351 | $uid, |
360 | 352 | $etag, |
361 | 353 | $resource_url, |
362 | - (string)$http_response->getBody(), |
|
354 | + (string) $http_response->getBody(), |
|
363 | 355 | $http_response->getStatusCode() |
364 | 356 | ); |
365 | 357 | } |
@@ -376,20 +368,18 @@ discard block |
||
376 | 368 | $uid = $vo->getUID(); |
377 | 369 | $resource_url = $calendar_url.$uid.self::SchedulingInformationSuffix; |
378 | 370 | $http_response = $this->makeRequest( |
379 | - RequestFactory::createPutRequest |
|
380 | - ( |
|
371 | + RequestFactory::createPutRequest( |
|
381 | 372 | $resource_url, |
382 | 373 | CalDAVRequestFactory::getInstance()->build(CalDAVRequestFactory::EventUpdateRequestType, [$vo])->getContent(), |
383 | 374 | $etag |
384 | 375 | ) |
385 | 376 | ); |
386 | 377 | $etag = $http_response->hasHeader(self::ETagHeader) ? $http_response->getHeaderLine(self::ETagHeader) : null; |
387 | - return new EventUpdatedResponse |
|
388 | - ( |
|
378 | + return new EventUpdatedResponse( |
|
389 | 379 | $uid, |
390 | 380 | $etag, |
391 | 381 | $resource_url, |
392 | - (string)$http_response->getBody(), |
|
382 | + (string) $http_response->getBody(), |
|
393 | 383 | $http_response->getStatusCode() |
394 | 384 | ); |
395 | 385 | } |
@@ -404,16 +394,14 @@ discard block |
||
404 | 394 | public function deleteEvent($calendar_url, $uid, $etag = null) |
405 | 395 | { |
406 | 396 | $http_response = $this->makeRequest( |
407 | - RequestFactory::createDeleteRequest |
|
408 | - ( |
|
397 | + RequestFactory::createDeleteRequest( |
|
409 | 398 | $calendar_url.$uid.self::SchedulingInformationSuffix, |
410 | 399 | $etag |
411 | 400 | ) |
412 | 401 | ); |
413 | 402 | |
414 | - return new EventDeletedResponse |
|
415 | - ( |
|
416 | - (string)$http_response->getBody(), $http_response->getStatusCode() |
|
403 | + return new EventDeletedResponse( |
|
404 | + (string) $http_response->getBody(), $http_response->getStatusCode() |
|
417 | 405 | ); |
418 | 406 | } |
419 | 407 | |
@@ -422,15 +410,14 @@ discard block |
||
422 | 410 | * @return string |
423 | 411 | * @throws \GuzzleHttp\Exception\GuzzleException |
424 | 412 | */ |
425 | - public function getEventVCardBy($event_url){ |
|
413 | + public function getEventVCardBy($event_url) { |
|
426 | 414 | $http_response = $this->makeRequest( |
427 | - RequestFactory::createGetRequest |
|
428 | - ( |
|
415 | + RequestFactory::createGetRequest( |
|
429 | 416 | $event_url |
430 | 417 | ) |
431 | 418 | ); |
432 | 419 | |
433 | - $ical = (string)$http_response->getBody(); |
|
420 | + $ical = (string) $http_response->getBody(); |
|
434 | 421 | return $ical; |
435 | 422 | } |
436 | 423 | |
@@ -443,17 +430,15 @@ discard block |
||
443 | 430 | public function getEventsBy($calendar_url, array $events_urls) |
444 | 431 | { |
445 | 432 | $http_response = $this->makeRequest( |
446 | - RequestFactory::createReportRequest |
|
447 | - ( |
|
433 | + RequestFactory::createReportRequest( |
|
448 | 434 | $calendar_url, |
449 | 435 | CalDAVRequestFactory::getInstance()->build(CalDAVRequestFactory::CalendarMultiGetRequestType, [$events_urls])->getContent() |
450 | 436 | ) |
451 | 437 | ); |
452 | 438 | |
453 | - return new ResourceCollectionResponse |
|
454 | - ( |
|
439 | + return new ResourceCollectionResponse( |
|
455 | 440 | $this->server_url, |
456 | - (string)$http_response->getBody(), |
|
441 | + (string) $http_response->getBody(), |
|
457 | 442 | $http_response->getStatusCode() |
458 | 443 | ); |
459 | 444 | } |
@@ -468,17 +453,15 @@ discard block |
||
468 | 453 | { |
469 | 454 | |
470 | 455 | $http_response = $this->makeRequest( |
471 | - RequestFactory::createReportRequest |
|
472 | - ( |
|
456 | + RequestFactory::createReportRequest( |
|
473 | 457 | $calendar_url, |
474 | 458 | CalDAVRequestFactory::getInstance()->build(CalDAVRequestFactory::CalendarQueryRequestType, [$filter])->getContent() |
475 | 459 | ) |
476 | 460 | ); |
477 | 461 | |
478 | - return new ResourceCollectionResponse |
|
479 | - ( |
|
462 | + return new ResourceCollectionResponse( |
|
480 | 463 | $this->server_url, |
481 | - (string)$http_response->getBody(), |
|
464 | + (string) $http_response->getBody(), |
|
482 | 465 | $http_response->getStatusCode() |
483 | 466 | ); |
484 | 467 | } |
@@ -492,16 +475,14 @@ discard block |
||
492 | 475 | public function deleteCalendar($calendar_url, $etag = null) |
493 | 476 | { |
494 | 477 | $http_response = $this->makeRequest( |
495 | - RequestFactory::createDeleteRequest |
|
496 | - ( |
|
478 | + RequestFactory::createDeleteRequest( |
|
497 | 479 | $calendar_url, |
498 | 480 | $etag |
499 | 481 | ) |
500 | 482 | ); |
501 | 483 | |
502 | - return new CalendarDeletedResponse |
|
503 | - ( |
|
504 | - (string)$http_response->getBody(), $http_response->getStatusCode() |
|
484 | + return new CalendarDeletedResponse( |
|
485 | + (string) $http_response->getBody(), $http_response->getStatusCode() |
|
505 | 486 | ); |
506 | 487 | } |
507 | 488 | } |
@@ -175,8 +175,7 @@ |
||
175 | 175 | } |
176 | 176 | |
177 | 177 | return $this->client->send($http_request, $options); |
178 | - } |
|
179 | - catch (ClientException $ex){ |
|
178 | + } catch (ClientException $ex){ |
|
180 | 179 | switch($ex->getCode()){ |
181 | 180 | case 401: |
182 | 181 | throw new UserUnAuthorizedException(); |