@@ -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,15 +226,14 @@ 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 | 0 |
| 234 | 233 | ) |
| 235 | 234 | ); |
| 236 | 235 | |
| 237 | - return new UserPrincipalResponse($this->server_url, (string)$http_response->getBody(), $http_response->getStatusCode()); |
|
| 236 | + return new UserPrincipalResponse($this->server_url, (string) $http_response->getBody(), $http_response->getStatusCode()); |
|
| 238 | 237 | } |
| 239 | 238 | |
| 240 | 239 | /** |
@@ -245,15 +244,14 @@ discard block |
||
| 245 | 244 | public function getCalendarHome($principal_url) |
| 246 | 245 | { |
| 247 | 246 | $http_response = $this->makeRequest( |
| 248 | - RequestFactory::createPropFindRequest |
|
| 249 | - ( |
|
| 247 | + RequestFactory::createPropFindRequest( |
|
| 250 | 248 | $principal_url, |
| 251 | 249 | CalDAVRequestFactory::getInstance()->build(CalDAVRequestFactory::CalendarHomeRequestType)->getContent(), |
| 252 | 250 | 0 |
| 253 | 251 | ) |
| 254 | 252 | ); |
| 255 | 253 | |
| 256 | - return new CalendarHomesResponse($this->server_url, (string)$http_response->getBody(), $http_response->getStatusCode()); |
|
| 254 | + return new CalendarHomesResponse($this->server_url, (string) $http_response->getBody(), $http_response->getStatusCode()); |
|
| 257 | 255 | } |
| 258 | 256 | |
| 259 | 257 | /** |
@@ -268,10 +266,9 @@ discard block |
||
| 268 | 266 | $uid = $vo->getUID(); |
| 269 | 267 | $resource_name = $vo->getResourceName(); |
| 270 | 268 | |
| 271 | - $resource_url = $calendar_home_set . ($resource_name ? $resource_name : $uid); |
|
| 269 | + $resource_url = $calendar_home_set.($resource_name ? $resource_name : $uid); |
|
| 272 | 270 | $http_response = $this->makeRequest( |
| 273 | - RequestFactory::createMakeCalendarRequest |
|
| 274 | - ( |
|
| 271 | + RequestFactory::createMakeCalendarRequest( |
|
| 275 | 272 | $resource_url, |
| 276 | 273 | CalDAVRequestFactory::getInstance()->build(CalDAVRequestFactory::CalendarCreateRequestType, [$vo])->getContent() |
| 277 | 274 | ) |
@@ -288,14 +285,13 @@ discard block |
||
| 288 | 285 | public function getCalendars($calendar_home_set_url) |
| 289 | 286 | { |
| 290 | 287 | $http_response = $this->makeRequest( |
| 291 | - RequestFactory::createPropFindRequest |
|
| 292 | - ( |
|
| 288 | + RequestFactory::createPropFindRequest( |
|
| 293 | 289 | $calendar_home_set_url, |
| 294 | 290 | CalDAVRequestFactory::getInstance()->build(CalDAVRequestFactory::CalendarsRequestType)->getContent() |
| 295 | 291 | ) |
| 296 | 292 | ); |
| 297 | 293 | |
| 298 | - return new GetCalendarsResponse($this->server_url, (string)$http_response->getBody(), $http_response->getStatusCode()); |
|
| 294 | + return new GetCalendarsResponse($this->server_url, (string) $http_response->getBody(), $http_response->getStatusCode()); |
|
| 299 | 295 | } |
| 300 | 296 | |
| 301 | 297 | /** |
@@ -306,15 +302,14 @@ discard block |
||
| 306 | 302 | public function getCalendar($calendar_url) |
| 307 | 303 | { |
| 308 | 304 | $http_response = $this->makeRequest( |
| 309 | - RequestFactory::createPropFindRequest |
|
| 310 | - ( |
|
| 305 | + RequestFactory::createPropFindRequest( |
|
| 311 | 306 | $calendar_url, |
| 312 | 307 | CalDAVRequestFactory::getInstance()->build(CalDAVRequestFactory::CalendarRequestType)->getContent(), |
| 313 | 308 | 0 |
| 314 | 309 | ) |
| 315 | 310 | ); |
| 316 | 311 | |
| 317 | - return new GetCalendarResponse($this->server_url, (string)$http_response->getBody(), $http_response->getStatusCode()); |
|
| 312 | + return new GetCalendarResponse($this->server_url, (string) $http_response->getBody(), $http_response->getStatusCode()); |
|
| 318 | 313 | } |
| 319 | 314 | |
| 320 | 315 | |
@@ -328,14 +323,13 @@ discard block |
||
| 328 | 323 | { |
| 329 | 324 | |
| 330 | 325 | $http_response = $this->makeRequest( |
| 331 | - RequestFactory::createReportRequest |
|
| 332 | - ( |
|
| 326 | + RequestFactory::createReportRequest( |
|
| 333 | 327 | $calendar_url, |
| 334 | 328 | CalDAVRequestFactory::getInstance()->build(CalDAVRequestFactory::CalendarSyncRequestType, [$sync_token])->getContent() |
| 335 | 329 | ) |
| 336 | 330 | ); |
| 337 | 331 | |
| 338 | - return new CalendarSyncInfoResponse($this->server_url, (string)$http_response->getBody(), $http_response->getStatusCode()); |
|
| 332 | + return new CalendarSyncInfoResponse($this->server_url, (string) $http_response->getBody(), $http_response->getStatusCode()); |
|
| 339 | 333 | } |
| 340 | 334 | |
| 341 | 335 | /** |
@@ -349,19 +343,17 @@ discard block |
||
| 349 | 343 | $uid = $vo->getUID(); |
| 350 | 344 | $resource_url = $calendar_url.$uid.self::SchedulingInformationSuffix; |
| 351 | 345 | $http_response = $this->makeRequest( |
| 352 | - RequestFactory::createPutRequest |
|
| 353 | - ( |
|
| 346 | + RequestFactory::createPutRequest( |
|
| 354 | 347 | $resource_url, |
| 355 | 348 | CalDAVRequestFactory::getInstance()->build(CalDAVRequestFactory::EventCreateRequestType, [$vo])->getContent() |
| 356 | 349 | ) |
| 357 | 350 | ); |
| 358 | 351 | $etag = $http_response->hasHeader(self::ETagHeader) ? $http_response->getHeaderLine(self::ETagHeader) : null; |
| 359 | - return new EventCreatedResponse |
|
| 360 | - ( |
|
| 352 | + return new EventCreatedResponse( |
|
| 361 | 353 | $uid, |
| 362 | 354 | $etag, |
| 363 | 355 | $resource_url, |
| 364 | - (string)$http_response->getBody(), |
|
| 356 | + (string) $http_response->getBody(), |
|
| 365 | 357 | $http_response->getStatusCode() |
| 366 | 358 | ); |
| 367 | 359 | } |
@@ -378,20 +370,18 @@ discard block |
||
| 378 | 370 | $uid = $vo->getUID(); |
| 379 | 371 | $resource_url = $calendar_url.$uid.self::SchedulingInformationSuffix; |
| 380 | 372 | $http_response = $this->makeRequest( |
| 381 | - RequestFactory::createPutRequest |
|
| 382 | - ( |
|
| 373 | + RequestFactory::createPutRequest( |
|
| 383 | 374 | $resource_url, |
| 384 | 375 | CalDAVRequestFactory::getInstance()->build(CalDAVRequestFactory::EventUpdateRequestType, [$vo])->getContent(), |
| 385 | 376 | $etag |
| 386 | 377 | ) |
| 387 | 378 | ); |
| 388 | 379 | $etag = $http_response->hasHeader(self::ETagHeader) ? $http_response->getHeaderLine(self::ETagHeader) : null; |
| 389 | - return new EventUpdatedResponse |
|
| 390 | - ( |
|
| 380 | + return new EventUpdatedResponse( |
|
| 391 | 381 | $uid, |
| 392 | 382 | $etag, |
| 393 | 383 | $resource_url, |
| 394 | - (string)$http_response->getBody(), |
|
| 384 | + (string) $http_response->getBody(), |
|
| 395 | 385 | $http_response->getStatusCode() |
| 396 | 386 | ); |
| 397 | 387 | } |
@@ -406,16 +396,14 @@ discard block |
||
| 406 | 396 | public function deleteEvent($calendar_url, $uid, $etag = null) |
| 407 | 397 | { |
| 408 | 398 | $http_response = $this->makeRequest( |
| 409 | - RequestFactory::createDeleteRequest |
|
| 410 | - ( |
|
| 399 | + RequestFactory::createDeleteRequest( |
|
| 411 | 400 | $calendar_url.$uid.self::SchedulingInformationSuffix, |
| 412 | 401 | $etag |
| 413 | 402 | ) |
| 414 | 403 | ); |
| 415 | 404 | |
| 416 | - return new EventDeletedResponse |
|
| 417 | - ( |
|
| 418 | - (string)$http_response->getBody(), $http_response->getStatusCode() |
|
| 405 | + return new EventDeletedResponse( |
|
| 406 | + (string) $http_response->getBody(), $http_response->getStatusCode() |
|
| 419 | 407 | ); |
| 420 | 408 | } |
| 421 | 409 | |
@@ -424,15 +412,14 @@ discard block |
||
| 424 | 412 | * @return string |
| 425 | 413 | * @throws \GuzzleHttp\Exception\GuzzleException |
| 426 | 414 | */ |
| 427 | - public function getEventVCardBy($event_url){ |
|
| 415 | + public function getEventVCardBy($event_url) { |
|
| 428 | 416 | $http_response = $this->makeRequest( |
| 429 | - RequestFactory::createGetRequest |
|
| 430 | - ( |
|
| 417 | + RequestFactory::createGetRequest( |
|
| 431 | 418 | $event_url |
| 432 | 419 | ) |
| 433 | 420 | ); |
| 434 | 421 | |
| 435 | - $ical = (string)$http_response->getBody(); |
|
| 422 | + $ical = (string) $http_response->getBody(); |
|
| 436 | 423 | return $ical; |
| 437 | 424 | } |
| 438 | 425 | |
@@ -445,17 +432,15 @@ discard block |
||
| 445 | 432 | public function getEventsBy($calendar_url, array $events_urls) |
| 446 | 433 | { |
| 447 | 434 | $http_response = $this->makeRequest( |
| 448 | - RequestFactory::createReportRequest |
|
| 449 | - ( |
|
| 435 | + RequestFactory::createReportRequest( |
|
| 450 | 436 | $calendar_url, |
| 451 | 437 | CalDAVRequestFactory::getInstance()->build(CalDAVRequestFactory::CalendarMultiGetRequestType, [$events_urls])->getContent() |
| 452 | 438 | ) |
| 453 | 439 | ); |
| 454 | 440 | |
| 455 | - return new ResourceCollectionResponse |
|
| 456 | - ( |
|
| 441 | + return new ResourceCollectionResponse( |
|
| 457 | 442 | $this->server_url, |
| 458 | - (string)$http_response->getBody(), |
|
| 443 | + (string) $http_response->getBody(), |
|
| 459 | 444 | $http_response->getStatusCode() |
| 460 | 445 | ); |
| 461 | 446 | } |
@@ -470,17 +455,15 @@ discard block |
||
| 470 | 455 | { |
| 471 | 456 | |
| 472 | 457 | $http_response = $this->makeRequest( |
| 473 | - RequestFactory::createReportRequest |
|
| 474 | - ( |
|
| 458 | + RequestFactory::createReportRequest( |
|
| 475 | 459 | $calendar_url, |
| 476 | 460 | CalDAVRequestFactory::getInstance()->build(CalDAVRequestFactory::CalendarQueryRequestType, [$filter])->getContent() |
| 477 | 461 | ) |
| 478 | 462 | ); |
| 479 | 463 | |
| 480 | - return new ResourceCollectionResponse |
|
| 481 | - ( |
|
| 464 | + return new ResourceCollectionResponse( |
|
| 482 | 465 | $this->server_url, |
| 483 | - (string)$http_response->getBody(), |
|
| 466 | + (string) $http_response->getBody(), |
|
| 484 | 467 | $http_response->getStatusCode() |
| 485 | 468 | ); |
| 486 | 469 | } |
@@ -494,16 +477,14 @@ discard block |
||
| 494 | 477 | public function deleteCalendar($calendar_url, $etag = null) |
| 495 | 478 | { |
| 496 | 479 | $http_response = $this->makeRequest( |
| 497 | - RequestFactory::createDeleteRequest |
|
| 498 | - ( |
|
| 480 | + RequestFactory::createDeleteRequest( |
|
| 499 | 481 | $calendar_url, |
| 500 | 482 | $etag |
| 501 | 483 | ) |
| 502 | 484 | ); |
| 503 | 485 | |
| 504 | - return new CalendarDeletedResponse |
|
| 505 | - ( |
|
| 506 | - (string)$http_response->getBody(), $http_response->getStatusCode() |
|
| 486 | + return new CalendarDeletedResponse( |
|
| 487 | + (string) $http_response->getBody(), $http_response->getStatusCode() |
|
| 507 | 488 | ); |
| 508 | 489 | } |
| 509 | 490 | } |
@@ -22,11 +22,11 @@ |
||
| 22 | 22 | * @return string |
| 23 | 23 | */ |
| 24 | 24 | public function getPrincipalUrl() { |
| 25 | - $url = isset($this->found_props['current-user-principal']) && isset($this->found_props['current-user-principal']['href']) ? |
|
| 25 | + $url = isset($this->found_props['current-user-principal']) && isset($this->found_props['current-user-principal']['href']) ? |
|
| 26 | 26 | $this->server_url.$this->found_props['current-user-principal']['href'] : null; |
| 27 | 27 | // check on not found one ( issue on caldav icloud imp) |
| 28 | - if(empty($url)) |
|
| 29 | - $url = isset($this->not_found_props['current-user-principal']) && isset($this->not_found_props['current-user-principal']['href']) ? |
|
| 28 | + if (empty($url)) |
|
| 29 | + $url = isset($this->not_found_props['current-user-principal']) && isset($this->not_found_props['current-user-principal']['href']) ? |
|
| 30 | 30 | $this->server_url.$this->not_found_props['current-user-principal']['href'] : null; |
| 31 | 31 | return $url; |
| 32 | 32 | } |
@@ -25,9 +25,10 @@ |
||
| 25 | 25 | $url = isset($this->found_props['current-user-principal']) && isset($this->found_props['current-user-principal']['href']) ? |
| 26 | 26 | $this->server_url.$this->found_props['current-user-principal']['href'] : null; |
| 27 | 27 | // check on not found one ( issue on caldav icloud imp) |
| 28 | - if(empty($url)) |
|
| 29 | - $url = isset($this->not_found_props['current-user-principal']) && isset($this->not_found_props['current-user-principal']['href']) ? |
|
| 28 | + if(empty($url)) { |
|
| 29 | + $url = isset($this->not_found_props['current-user-principal']) && isset($this->not_found_props['current-user-principal']['href']) ? |
|
| 30 | 30 | $this->server_url.$this->not_found_props['current-user-principal']['href'] : null; |
| 31 | + } |
|
| 31 | 32 | return $url; |
| 32 | 33 | } |
| 33 | 34 | } |
| 34 | 35 | \ No newline at end of file |