@@ -22,24 +22,24 @@ discard block |
||
22 | 22 | /** |
23 | 23 | * @return string|null |
24 | 24 | */ |
25 | - public function getSyncToken(){ |
|
26 | - return isset($this->content['sync-token'])? $this->content['sync-token'] : null; |
|
25 | + public function getSyncToken() { |
|
26 | + return isset($this->content['sync-token']) ? $this->content['sync-token'] : null; |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | /** |
30 | 30 | * @return bool |
31 | 31 | */ |
32 | - public function hasAvailableChanges(){ |
|
32 | + public function hasAvailableChanges() { |
|
33 | 33 | return count($this->responses) > 0; |
34 | 34 | } |
35 | 35 | |
36 | 36 | /** |
37 | 37 | * @return ETagEntityResponse[] |
38 | 38 | */ |
39 | - public function getUpdates(){ |
|
39 | + public function getUpdates() { |
|
40 | 40 | $res = []; |
41 | - foreach ($this->responses as $entity){ |
|
42 | - if($entity instanceof ETagEntityResponse && $entity->getStatus() != HttpResponse::HttpOKStatus) continue; |
|
41 | + foreach ($this->responses as $entity) { |
|
42 | + if ($entity instanceof ETagEntityResponse && $entity->getStatus() != HttpResponse::HttpOKStatus) continue; |
|
43 | 43 | $res[] = $entity; |
44 | 44 | } |
45 | 45 | return $res; |
@@ -48,10 +48,10 @@ discard block |
||
48 | 48 | /** |
49 | 49 | * @return ETagEntityResponse[] |
50 | 50 | */ |
51 | - public function getDeletes(){ |
|
51 | + public function getDeletes() { |
|
52 | 52 | $res = []; |
53 | - foreach ($this->responses as $entity){ |
|
54 | - if($entity instanceof ETagEntityResponse && $entity->getStatus() != HttpResponse::HttpNotFoundStatus) continue; |
|
53 | + foreach ($this->responses as $entity) { |
|
54 | + if ($entity instanceof ETagEntityResponse && $entity->getStatus() != HttpResponse::HttpNotFoundStatus) continue; |
|
55 | 55 | $res[] = $entity; |
56 | 56 | } |
57 | 57 | return $res; |
@@ -39,7 +39,9 @@ discard block |
||
39 | 39 | public function getUpdates(){ |
40 | 40 | $res = []; |
41 | 41 | foreach ($this->responses as $entity){ |
42 | - if($entity instanceof ETagEntityResponse && $entity->getStatus() != HttpResponse::HttpOKStatus) continue; |
|
42 | + if($entity instanceof ETagEntityResponse && $entity->getStatus() != HttpResponse::HttpOKStatus) { |
|
43 | + continue; |
|
44 | + } |
|
43 | 45 | $res[] = $entity; |
44 | 46 | } |
45 | 47 | return $res; |
@@ -51,7 +53,9 @@ discard block |
||
51 | 53 | public function getDeletes(){ |
52 | 54 | $res = []; |
53 | 55 | foreach ($this->responses as $entity){ |
54 | - if($entity instanceof ETagEntityResponse && $entity->getStatus() != HttpResponse::HttpNotFoundStatus) continue; |
|
56 | + if($entity instanceof ETagEntityResponse && $entity->getStatus() != HttpResponse::HttpNotFoundStatus) { |
|
57 | + continue; |
|
58 | + } |
|
55 | 59 | $res[] = $entity; |
56 | 60 | } |
57 | 61 | return $res; |
@@ -46,14 +46,14 @@ |
||
46 | 46 | * @param DateTime $from |
47 | 47 | * @param DateTime $to |
48 | 48 | */ |
49 | - public function __construct($get_etags = true, $get_calendar_data = false, DateTime $from = null, DateTime $to = null) |
|
49 | + public function __construct($get_etags = true, $get_calendar_data = false, DateTime $from = null, DateTime $to = null) |
|
50 | 50 | { |
51 | 51 | $this->get_etags = $get_etags; |
52 | 52 | $this->get_calendar_data = $get_calendar_data; |
53 | 53 | $this->from = $from; |
54 | 54 | $this->to = $to; |
55 | 55 | |
56 | - if(!is_null($this->from) && !is_null($this->to) && $this->from > $this->to) |
|
56 | + if (!is_null($this->from) && !is_null($this->to) && $this->from > $this->to) |
|
57 | 57 | throw new \InvalidArgumentException("from should be lower than to param"); |
58 | 58 | } |
59 | 59 |
@@ -53,8 +53,9 @@ |
||
53 | 53 | $this->from = $from; |
54 | 54 | $this->to = $to; |
55 | 55 | |
56 | - if(!is_null($this->from) && !is_null($this->to) && $this->from > $this->to) |
|
57 | - throw new \InvalidArgumentException("from should be lower than to param"); |
|
56 | + if(!is_null($this->from) && !is_null($this->to) && $this->from > $this->to) { |
|
57 | + throw new \InvalidArgumentException("from should be lower than to param"); |
|
58 | + } |
|
58 | 59 | } |
59 | 60 | |
60 | 61 | /** |
@@ -30,13 +30,13 @@ |
||
30 | 30 | * @param string $type |
31 | 31 | * @return array |
32 | 32 | */ |
33 | - public function getResponseByType($type){ |
|
33 | + public function getResponseByType($type) { |
|
34 | 34 | $responses = []; |
35 | 35 | |
36 | - foreach ($this->getResponses() as $response){ |
|
37 | - if(!$response instanceof GetCalendarResponse) continue; |
|
36 | + foreach ($this->getResponses() as $response) { |
|
37 | + if (!$response instanceof GetCalendarResponse) continue; |
|
38 | 38 | $resource_types = $response->getResourceType(); |
39 | - if(in_array($type, array_keys($resource_types))) $responses[] = $response; |
|
39 | + if (in_array($type, array_keys($resource_types))) $responses[] = $response; |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | return $responses; |
@@ -34,9 +34,13 @@ |
||
34 | 34 | $responses = []; |
35 | 35 | |
36 | 36 | foreach ($this->getResponses() as $response){ |
37 | - if(!$response instanceof GetCalendarResponse) continue; |
|
37 | + if(!$response instanceof GetCalendarResponse) { |
|
38 | + continue; |
|
39 | + } |
|
38 | 40 | $resource_types = $response->getResourceType(); |
39 | - if(in_array($type, array_keys($resource_types))) $responses[] = $response; |
|
41 | + if(in_array($type, array_keys($resource_types))) { |
|
42 | + $responses[] = $response; |
|
43 | + } |
|
40 | 44 | } |
41 | 45 | |
42 | 46 | return $responses; |
@@ -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(); |
@@ -22,11 +22,11 @@ discard block |
||
22 | 22 | /** |
23 | 23 | * @return string |
24 | 24 | */ |
25 | - public function getDisplayName(){ |
|
25 | + public function getDisplayName() { |
|
26 | 26 | return isset($this->found_props['displayname']) ? $this->found_props['displayname'] : null; |
27 | 27 | } |
28 | 28 | |
29 | - public function getResourceType(){ |
|
29 | + public function getResourceType() { |
|
30 | 30 | return isset($this->found_props['resourcetype']) ? $this->found_props['resourcetype'] : null; |
31 | 31 | } |
32 | 32 | |
@@ -34,21 +34,21 @@ discard block |
||
34 | 34 | * @see https://tools.ietf.org/html/rfc6578 |
35 | 35 | * @return string |
36 | 36 | */ |
37 | - public function getSyncToken(){ |
|
37 | + public function getSyncToken() { |
|
38 | 38 | return isset($this->found_props['sync-token']) ? $this->found_props['sync-token'] : null; |
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
42 | 42 | * @return string |
43 | 43 | */ |
44 | - public function getETag(){ |
|
44 | + public function getETag() { |
|
45 | 45 | return isset($this->found_props['getetag']) ? $this->found_props['getetag'] : null; |
46 | 46 | } |
47 | 47 | |
48 | 48 | /** |
49 | 49 | * @return string |
50 | 50 | */ |
51 | - public function getCTag(){ |
|
51 | + public function getCTag() { |
|
52 | 52 | return isset($this->found_props['getctag']) ? $this->found_props['getctag'] : null; |
53 | 53 | } |
54 | 54 |
@@ -42,15 +42,15 @@ discard block |
||
42 | 42 | * @param string|null $body |
43 | 43 | * @param int $code |
44 | 44 | */ |
45 | - public function __construct($server_url = null, $body = null, $code = HttpResponse::HttpCodeOk ) |
|
45 | + public function __construct($server_url = null, $body = null, $code = HttpResponse::HttpCodeOk) |
|
46 | 46 | { |
47 | 47 | parent::__construct($body, $code); |
48 | 48 | $this->server_url = $server_url; |
49 | - if(!empty($this->body)) { |
|
49 | + if (!empty($this->body)) { |
|
50 | 50 | $this->stripped = $this->stripNamespacesFromTags($this->body); |
51 | 51 | // Merge CDATA as text nodes |
52 | 52 | $this->xml = simplexml_load_string($this->stripped, null, LIBXML_NOCDATA); |
53 | - if($this->xml === FALSE) |
|
53 | + if ($this->xml === FALSE) |
|
54 | 54 | throw new XMLResponseParseException(); |
55 | 55 | $this->content = $this->toAssocArray($this->xml); |
56 | 56 | |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | { |
63 | 63 | } |
64 | 64 | |
65 | - protected function setContent($content){ |
|
65 | + protected function setContent($content) { |
|
66 | 66 | $this->content = $content; |
67 | 67 | } |
68 | 68 | |
@@ -95,13 +95,13 @@ discard block |
||
95 | 95 | $nameSpaceDefRegEx = '(\S+)=["\']?((?:.(?!["\']?\s+(?:\S+)=|[>"\']))+.)["\']?'; |
96 | 96 | |
97 | 97 | // Cycle through each namespace and remove it from the XML string |
98 | - foreach( $toRemove as $remove ) { |
|
98 | + foreach ($toRemove as $remove) { |
|
99 | 99 | // First remove the namespace from the opening of the tag |
100 | - $xml = str_replace('<' . $remove . ':', '<', $xml); |
|
100 | + $xml = str_replace('<'.$remove.':', '<', $xml); |
|
101 | 101 | // Now remove the namespace from the closing of the tag |
102 | - $xml = str_replace('</' . $remove . ':', '</', $xml); |
|
102 | + $xml = str_replace('</'.$remove.':', '</', $xml); |
|
103 | 103 | // This XML uses the name space with CommentText, so remove that too |
104 | - $xml = str_replace($remove . ':commentText', 'commentText', $xml); |
|
104 | + $xml = str_replace($remove.':commentText', 'commentText', $xml); |
|
105 | 105 | // Complete the pattern for RegEx to remove this namespace declaration |
106 | 106 | $pattern = "/xmlns:{$remove}{$nameSpaceDefRegEx}/"; |
107 | 107 | // Remove the actual namespace declaration using the Pattern |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | /** |
126 | 126 | * @return bool |
127 | 127 | */ |
128 | - protected function isValid(){ |
|
128 | + protected function isValid() { |
|
129 | 129 | return isset($this->content['response']); |
130 | 130 | } |
131 | 131 | } |
132 | 132 | \ No newline at end of file |
@@ -50,8 +50,9 @@ |
||
50 | 50 | $this->stripped = $this->stripNamespacesFromTags($this->body); |
51 | 51 | // Merge CDATA as text nodes |
52 | 52 | $this->xml = simplexml_load_string($this->stripped, null, LIBXML_NOCDATA); |
53 | - if($this->xml === FALSE) |
|
54 | - throw new XMLResponseParseException(); |
|
53 | + if($this->xml === FALSE) { |
|
54 | + throw new XMLResponseParseException(); |
|
55 | + } |
|
55 | 56 | $this->content = $this->toAssocArray($this->xml); |
56 | 57 | |
57 | 58 | $this->parse(); |
@@ -21,10 +21,10 @@ |
||
21 | 21 | /** |
22 | 22 | * @return string |
23 | 23 | */ |
24 | - public function getVCard(){ |
|
25 | - if(!isset($this->found_props['calendar-data'])) return null; |
|
24 | + public function getVCard() { |
|
25 | + if (!isset($this->found_props['calendar-data'])) return null; |
|
26 | 26 | $calendar_data = $this->found_props['calendar-data']; |
27 | - if(!is_string($calendar_data)) return null; |
|
27 | + if (!is_string($calendar_data)) return null; |
|
28 | 28 | return $calendar_data; |
29 | 29 | } |
30 | 30 | } |
31 | 31 | \ No newline at end of file |
@@ -22,9 +22,13 @@ |
||
22 | 22 | * @return string |
23 | 23 | */ |
24 | 24 | public function getVCard(){ |
25 | - if(!isset($this->found_props['calendar-data'])) return null; |
|
25 | + if(!isset($this->found_props['calendar-data'])) { |
|
26 | + return null; |
|
27 | + } |
|
26 | 28 | $calendar_data = $this->found_props['calendar-data']; |
27 | - if(!is_string($calendar_data)) return null; |
|
29 | + if(!is_string($calendar_data)) { |
|
30 | + return null; |
|
31 | + } |
|
28 | 32 | return $calendar_data; |
29 | 33 | } |
30 | 34 | } |
31 | 35 | \ No newline at end of file |
@@ -51,27 +51,27 @@ discard block |
||
51 | 51 | case HttpMethods::Put: |
52 | 52 | |
53 | 53 | $len = $params[0]; |
54 | - $etag = $params[1]; |
|
54 | + $etag = $params[1]; |
|
55 | 55 | |
56 | - $headers = [ |
|
57 | - Headers::ContentLength => intval($len), |
|
58 | - Headers::ContentType => ContentTypes::Calendar, |
|
59 | - ]; |
|
56 | + $headers = [ |
|
57 | + Headers::ContentLength => intval($len), |
|
58 | + Headers::ContentType => ContentTypes::Calendar, |
|
59 | + ]; |
|
60 | 60 | |
61 | - if(!empty($etag)){ |
|
62 | - $headers[Headers::IfMatch] = $etag; |
|
63 | - } |
|
61 | + if(!empty($etag)){ |
|
62 | + $headers[Headers::IfMatch] = $etag; |
|
63 | + } |
|
64 | 64 | |
65 | - return $headers; |
|
65 | + return $headers; |
|
66 | 66 | } |
67 | 67 | return []; |
68 | 68 | } |
69 | 69 | /** |
70 | - * @param string $url |
|
71 | - * @param string $body |
|
72 | - * @param int $depth |
|
73 | - * @return Request |
|
74 | - */ |
|
70 | + * @param string $url |
|
71 | + * @param string $body |
|
72 | + * @param int $depth |
|
73 | + * @return Request |
|
74 | + */ |
|
75 | 75 | public static function createPropFindRequest($url , $body, $depth = 1){ |
76 | 76 | return new Request |
77 | 77 | ( |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | * @param string $etag |
161 | 161 | * @return Request |
162 | 162 | */ |
163 | - public static function createPutRequest($url, $body, $etag = null){ |
|
163 | + public static function createPutRequest($url, $body, $etag = null){ |
|
164 | 164 | |
165 | 165 | return new Request |
166 | 166 | ( |
@@ -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 | ]; |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | Headers::ContentType => ContentTypes::Calendar, |
59 | 59 | ]; |
60 | 60 | |
61 | - if(!empty($etag)){ |
|
61 | + if (!empty($etag)) { |
|
62 | 62 | $headers[Headers::IfMatch] = $etag; |
63 | 63 | } |
64 | 64 | |
@@ -72,11 +72,10 @@ discard block |
||
72 | 72 | * @param int $depth |
73 | 73 | * @return Request |
74 | 74 | */ |
75 | - public static function createPropFindRequest($url , $body, $depth = 1){ |
|
76 | - return new Request |
|
77 | - ( |
|
75 | + public static function createPropFindRequest($url, $body, $depth = 1) { |
|
76 | + return new Request( |
|
78 | 77 | HttpMethods::PropFind, |
79 | - $url , |
|
78 | + $url, |
|
80 | 79 | self::createHeadersFor(HttpMethods::PropFind, [$depth]), |
81 | 80 | $body |
82 | 81 | ); |
@@ -87,9 +86,8 @@ discard block |
||
87 | 86 | * @param string $body |
88 | 87 | * @return Request |
89 | 88 | */ |
90 | - public static function createMakeCalendarRequest($url , $body){ |
|
91 | - return new Request |
|
92 | - ( |
|
89 | + public static function createMakeCalendarRequest($url, $body) { |
|
90 | + return new Request( |
|
93 | 91 | HttpMethods::MakeCalendar, |
94 | 92 | $url, |
95 | 93 | self::createHeadersFor(HttpMethods::MakeCalendar), |
@@ -102,9 +100,8 @@ discard block |
||
102 | 100 | * @param int $depth |
103 | 101 | * @return Request |
104 | 102 | */ |
105 | - public static function createOptionsRequest($url, $depth = 1){ |
|
106 | - return new Request |
|
107 | - ( |
|
103 | + public static function createOptionsRequest($url, $depth = 1) { |
|
104 | + return new Request( |
|
108 | 105 | HttpMethods::Options, |
109 | 106 | $url, |
110 | 107 | self::createHeadersFor(HttpMethods::Options, [$depth]) |
@@ -117,9 +114,8 @@ discard block |
||
117 | 114 | * @param int $depth |
118 | 115 | * @return Request |
119 | 116 | */ |
120 | - public static function createReportRequest($url , $body, $depth = 1){ |
|
121 | - return new Request |
|
122 | - ( |
|
117 | + public static function createReportRequest($url, $body, $depth = 1) { |
|
118 | + return new Request( |
|
123 | 119 | HttpMethods::Report, |
124 | 120 | $url, |
125 | 121 | self::createHeadersFor(HttpMethods::Report, [$depth]), |
@@ -132,9 +128,8 @@ discard block |
||
132 | 128 | * @param string $etag |
133 | 129 | * @return Request |
134 | 130 | */ |
135 | - public static function createDeleteRequest($url , $etag){ |
|
136 | - return new Request |
|
137 | - ( |
|
131 | + public static function createDeleteRequest($url, $etag) { |
|
132 | + return new Request( |
|
138 | 133 | HttpMethods::Delete, |
139 | 134 | $url, |
140 | 135 | self::createHeadersFor(HttpMethods::Delete, [$etag]) |
@@ -145,9 +140,8 @@ discard block |
||
145 | 140 | * @param string $url |
146 | 141 | * @return Request |
147 | 142 | */ |
148 | - public static function createGetRequest($url){ |
|
149 | - return new Request |
|
150 | - ( |
|
143 | + public static function createGetRequest($url) { |
|
144 | + return new Request( |
|
151 | 145 | HttpMethods::Get, |
152 | 146 | $url, |
153 | 147 | self::createHeadersFor(HttpMethods::Get) |
@@ -160,10 +154,9 @@ discard block |
||
160 | 154 | * @param string $etag |
161 | 155 | * @return Request |
162 | 156 | */ |
163 | - public static function createPutRequest($url, $body, $etag = null){ |
|
157 | + public static function createPutRequest($url, $body, $etag = null) { |
|
164 | 158 | |
165 | - return new Request |
|
166 | - ( |
|
159 | + return new Request( |
|
167 | 160 | HttpMethods::Put, |
168 | 161 | $url, |
169 | 162 | self::createHeadersFor(HttpMethods::Put, [strlen($body), $etag]), |
@@ -177,9 +170,8 @@ discard block |
||
177 | 170 | * @param string $etag |
178 | 171 | * @return Request |
179 | 172 | */ |
180 | - public static function createPostRequest($url, $body, $etag = null){ |
|
181 | - return new Request |
|
182 | - ( |
|
173 | + public static function createPostRequest($url, $body, $etag = null) { |
|
174 | + return new Request( |
|
183 | 175 | HttpMethods::Post, |
184 | 176 | $url, |
185 | 177 | self::createHeadersFor(HttpMethods::Post, [$etag]), |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | */ |
19 | 19 | final class CalDAVRequestFactory implements ICalDAVRequestFactory |
20 | 20 | { |
21 | - private function __construct(){} |
|
21 | + private function __construct() {} |
|
22 | 22 | |
23 | 23 | /** |
24 | 24 | * @var ICalDAVRequestFactory |
@@ -28,8 +28,8 @@ discard block |
||
28 | 28 | /** |
29 | 29 | * @return ICalDAVRequestFactory |
30 | 30 | */ |
31 | - public static function getInstance(){ |
|
32 | - if(is_null(self::$instance)) self::$instance = new CalDAVRequestFactory(); |
|
31 | + public static function getInstance() { |
|
32 | + if (is_null(self::$instance)) self::$instance = new CalDAVRequestFactory(); |
|
33 | 33 | return self::$instance; |
34 | 34 | } |
35 | 35 | |
@@ -47,8 +47,8 @@ discard block |
||
47 | 47 | * @return IAbstractWebDAVRequest|null |
48 | 48 | * @throws \InvalidArgumentException |
49 | 49 | */ |
50 | - public function build($type, $params = []){ |
|
51 | - switch(strtoupper($type)){ |
|
50 | + public function build($type, $params = []) { |
|
51 | + switch (strtoupper($type)) { |
|
52 | 52 | case self::PrincipalRequestType: |
53 | 53 | return new UserPrincipalRequest(); |
54 | 54 | case self::CalendarHomeRequestType: |
@@ -58,27 +58,27 @@ discard block |
||
58 | 58 | case self::CalendarRequestType: |
59 | 59 | return new GetCalendarRequest(); |
60 | 60 | case self::CalendarSyncRequestType: |
61 | - if(count($params) == 0 ) |
|
61 | + if (count($params) == 0) |
|
62 | 62 | throw new \InvalidArgumentException(); |
63 | 63 | return new CalendarSyncRequest($params[0]); |
64 | 64 | case self::CalendarMultiGetRequestType: |
65 | - if(count($params) == 0 ) |
|
65 | + if (count($params) == 0) |
|
66 | 66 | throw new \InvalidArgumentException(); |
67 | 67 | return new CalendarMultiGetRequest($params[0]); |
68 | 68 | case self::CalendarQueryRequestType: |
69 | - if(count($params) == 0 ) |
|
69 | + if (count($params) == 0) |
|
70 | 70 | throw new \InvalidArgumentException(); |
71 | 71 | return new CalendarQueryRequest($params[0]); |
72 | 72 | case self::CalendarCreateRequestType: |
73 | - if(count($params) == 0 ) |
|
73 | + if (count($params) == 0) |
|
74 | 74 | throw new \InvalidArgumentException(); |
75 | 75 | return new CalendarCreateRequest($params[0]); |
76 | 76 | case self::EventCreateRequestType: |
77 | - if(count($params) == 0 ) |
|
77 | + if (count($params) == 0) |
|
78 | 78 | throw new \InvalidArgumentException(); |
79 | 79 | return new EventCreateRequest($params[0]); |
80 | 80 | case self::EventUpdateRequestType: |
81 | - if(count($params) == 0 ) |
|
81 | + if (count($params) == 0) |
|
82 | 82 | throw new \InvalidArgumentException(); |
83 | 83 | return new EventUpdateRequest($params[0]); |
84 | 84 | } |
@@ -29,7 +29,9 @@ discard block |
||
29 | 29 | * @return ICalDAVRequestFactory |
30 | 30 | */ |
31 | 31 | public static function getInstance(){ |
32 | - if(is_null(self::$instance)) self::$instance = new CalDAVRequestFactory(); |
|
32 | + if(is_null(self::$instance)) { |
|
33 | + self::$instance = new CalDAVRequestFactory(); |
|
34 | + } |
|
33 | 35 | return self::$instance; |
34 | 36 | } |
35 | 37 | |
@@ -58,28 +60,34 @@ discard block |
||
58 | 60 | case self::CalendarRequestType: |
59 | 61 | return new GetCalendarRequest(); |
60 | 62 | case self::CalendarSyncRequestType: |
61 | - if(count($params) == 0 ) |
|
62 | - throw new \InvalidArgumentException(); |
|
63 | + if(count($params) == 0 ) { |
|
64 | + throw new \InvalidArgumentException(); |
|
65 | + } |
|
63 | 66 | return new CalendarSyncRequest($params[0]); |
64 | 67 | case self::CalendarMultiGetRequestType: |
65 | - if(count($params) == 0 ) |
|
66 | - throw new \InvalidArgumentException(); |
|
68 | + if(count($params) == 0 ) { |
|
69 | + throw new \InvalidArgumentException(); |
|
70 | + } |
|
67 | 71 | return new CalendarMultiGetRequest($params[0]); |
68 | 72 | case self::CalendarQueryRequestType: |
69 | - if(count($params) == 0 ) |
|
70 | - throw new \InvalidArgumentException(); |
|
73 | + if(count($params) == 0 ) { |
|
74 | + throw new \InvalidArgumentException(); |
|
75 | + } |
|
71 | 76 | return new CalendarQueryRequest($params[0]); |
72 | 77 | case self::CalendarCreateRequestType: |
73 | - if(count($params) == 0 ) |
|
74 | - throw new \InvalidArgumentException(); |
|
78 | + if(count($params) == 0 ) { |
|
79 | + throw new \InvalidArgumentException(); |
|
80 | + } |
|
75 | 81 | return new CalendarCreateRequest($params[0]); |
76 | 82 | case self::EventCreateRequestType: |
77 | - if(count($params) == 0 ) |
|
78 | - throw new \InvalidArgumentException(); |
|
83 | + if(count($params) == 0 ) { |
|
84 | + throw new \InvalidArgumentException(); |
|
85 | + } |
|
79 | 86 | return new EventCreateRequest($params[0]); |
80 | 87 | case self::EventUpdateRequestType: |
81 | - if(count($params) == 0 ) |
|
82 | - throw new \InvalidArgumentException(); |
|
88 | + if(count($params) == 0 ) { |
|
89 | + throw new \InvalidArgumentException(); |
|
90 | + } |
|
83 | 91 | return new EventUpdateRequest($params[0]); |
84 | 92 | } |
85 | 93 | return null; |